add fatal and nonfatal exceptions
This commit is contained in:
@@ -18,13 +18,38 @@ RageException::RageException( const char *fmt, ...)
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
m_sError = vssprintf( fmt, va );
|
||||
#ifdef _DEBUG
|
||||
MessageBox( NULL, m_sError, "Fatal Error", MB_OK );
|
||||
DebugBreak();
|
||||
#endif
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
RageException::RageException( const char *fmt, va_list va)
|
||||
{
|
||||
m_sError = vssprintf( fmt, va );
|
||||
}
|
||||
|
||||
const char* RageException::what() const throw ()
|
||||
{
|
||||
return m_sError;
|
||||
}
|
||||
|
||||
RageException::ThrowFatal(const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
CString error = vssprintf( fmt, va );
|
||||
va_end(va);
|
||||
|
||||
#if defined(WIN32) && defined(DEBUG)
|
||||
MessageBox( NULL, error, "Fatal Error", MB_OK );
|
||||
DebugBreak();
|
||||
#endif
|
||||
|
||||
throw RageException("%s", error);
|
||||
}
|
||||
|
||||
RageException::ThrowNonfatal(const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
|
||||
throw RageException(fmt, va);
|
||||
}
|
||||
|
||||
@@ -12,17 +12,27 @@
|
||||
*/
|
||||
|
||||
#include <exception>
|
||||
#include <stdarg.h>
|
||||
|
||||
class RageException : public exception
|
||||
{
|
||||
public:
|
||||
RageException( const char *fmt, ...);
|
||||
RageException( const char *fmt, va_list va);
|
||||
|
||||
virtual const char *what() const throw();
|
||||
virtual ~RageException() throw() { }
|
||||
|
||||
/* The only difference between these is that ThrowFatal triggers debug
|
||||
* behavior, and Nonfatal doesn't. Nonfatal is used when the exception
|
||||
* happens normally and will be caught, such as when a driver fails to
|
||||
* initialize. */
|
||||
static ThrowFatal(const char *fmt, ...);
|
||||
static ThrowNonfatal(const char *fmt, ...);
|
||||
|
||||
protected:
|
||||
CString m_sError;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user