// CatExcp.cpp : implementation file
//

#include "stdafx.h"
#include "sutl.h"
#include "CatExcp.h"
#define GCWINNT
#include "welog.h"
#undef GCWINNT

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCatException

IMPLEMENT_DYNCREATE(CCatException,CException)


CCatException::CCatException()
{
     m_errorCode=0;
}

CCatException::~CCatException()
{
}

VOID CCatException::SetError(
const INT ecode,
const CHAR *str,
...)
{
     va_list a;

     va_start(a,str);
     SetString(str,a);
     va_end(a);
     m_errorCode=ecode;
}

VOID CCatException::SetString(
const CHAR *str,
va_list args)
{
     LPTSTR tstr=m_errorString.GetBuffer(1024);
     vsprintf(tstr,str,args);
     m_errorString.ReleaseBuffer();
}

VOID CCatException::Catastro(VOID)
{
     HINSTANCE hInst;
     FARPROC pFunc;

     if ((hInst=LoadLibrary("wgswelog.dll")) != NULL) {
          if ((pFunc=GetProcAddress(hInst,"welogAdd")) != NULL){
               ((WELOGADD)pFunc)((LPCTSTR)m_errorString);
          }
          FreeLibrary(hInst);
     }
}

/////////////////////////////////////////////////////////////////////////////
// CCatException message handlers
