add fatal and nonfatal exceptions

This commit is contained in:
Glenn Maynard
2002-12-21 08:13:22 +00:00
parent 6ffd189d53
commit 4d1caeb4ce
2 changed files with 39 additions and 4 deletions
+29 -4
View File
@@ -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);
}
+10
View File
@@ -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