diff --git a/stepmania/src/RageException.cpp b/stepmania/src/RageException.cpp index 5772aeca6c..23a93af483 100644 --- a/stepmania/src/RageException.cpp +++ b/stepmania/src/RageException.cpp @@ -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); +} diff --git a/stepmania/src/RageException.h b/stepmania/src/RageException.h index b7ff52e064..50fb6517f0 100644 --- a/stepmania/src/RageException.h +++ b/stepmania/src/RageException.h @@ -12,17 +12,27 @@ */ #include +#include 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