2002-06-14 22:25:22 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: RageLog
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "RageException.h"
|
|
|
|
|
#include "RageUtil.h"
|
2002-12-21 18:12:03 +00:00
|
|
|
#include "RageLog.h"
|
2002-06-14 22:25:22 +00:00
|
|
|
|
2002-08-28 07:04:52 +00:00
|
|
|
RageException::RageException( const char *fmt, ...)
|
2002-06-14 22:25:22 +00:00
|
|
|
{
|
|
|
|
|
va_list va;
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
|
m_sError = vssprintf( fmt, va );
|
2002-12-21 08:13:22 +00:00
|
|
|
va_end(va);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RageException::RageException( const char *fmt, va_list va)
|
|
|
|
|
{
|
|
|
|
|
m_sError = vssprintf( fmt, va );
|
2002-06-14 22:25:22 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-16 09:12:55 +00:00
|
|
|
const char* RageException::what() const throw ()
|
2002-07-03 21:27:26 +00:00
|
|
|
{
|
|
|
|
|
return m_sError;
|
|
|
|
|
}
|
2002-12-21 08:13:22 +00:00
|
|
|
|
2002-12-22 03:19:46 +00:00
|
|
|
void RageException::Throw(const char *fmt, ...)
|
2002-12-21 08:13:22 +00:00
|
|
|
{
|
|
|
|
|
va_list va;
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
|
CString error = vssprintf( fmt, va );
|
|
|
|
|
va_end(va);
|
|
|
|
|
|
2002-12-21 18:12:03 +00:00
|
|
|
if(LOG)
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace("Fatal exception thrown: %s", error.GetString());
|
|
|
|
|
LOG->Flush();
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-21 08:13:22 +00:00
|
|
|
#if defined(WIN32) && defined(DEBUG)
|
|
|
|
|
MessageBox( NULL, error, "Fatal Error", MB_OK );
|
|
|
|
|
DebugBreak();
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-12-22 03:19:46 +00:00
|
|
|
throw RageException("%s", error.GetString());
|
2002-12-21 08:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
2002-12-22 03:19:46 +00:00
|
|
|
void RageException::ThrowNonfatal(const char *fmt, ...)
|
2002-12-21 08:13:22 +00:00
|
|
|
{
|
|
|
|
|
va_list va;
|
|
|
|
|
va_start(va, fmt);
|
|
|
|
|
|
2002-12-21 18:12:03 +00:00
|
|
|
if(LOG)
|
|
|
|
|
{
|
|
|
|
|
LOG->Trace("Nonfatal exception thrown: %s", vssprintf( fmt, va ).GetString());
|
|
|
|
|
LOG->Flush();
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-21 08:13:22 +00:00
|
|
|
throw RageException(fmt, va);
|
|
|
|
|
}
|