Files
itgmania212121/stepmania/src/RageException.cpp
T

74 lines
1.4 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-06-14 22:25:22 +00:00
/*
-----------------------------------------------------------------------------
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"
#include "RageLog.h"
2004-01-31 01:23:20 +00:00
#if defined(_WINDOWS) && defined(DEBUG)
#include "windows.h"
#endif
2002-06-14 22:25:22 +00:00
2003-12-21 21:34:01 +00:00
RageException::RageException( const CString &str ):
m_sError(str)
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);
2003-02-14 19:00:37 +00:00
CString msg = ssprintf(
"\n"
"//////////////////////////////////////////////////////\n"
"Exception: %s\n"
"//////////////////////////////////////////////////////\n"
"",
2003-04-25 00:01:35 +00:00
error.c_str());
2002-12-21 18:12:03 +00:00
if(LOG)
{
2003-04-25 00:01:35 +00:00
LOG->Trace("%s", msg.c_str());
2002-12-21 18:12:03 +00:00
LOG->Flush();
}
2003-02-14 19:00:37 +00:00
else
{
2003-04-25 00:01:35 +00:00
printf("%s\n", msg.c_str());
2003-02-14 19:00:37 +00:00
fflush(stdout);
}
2002-12-21 18:12:03 +00:00
2004-01-31 01:23:20 +00:00
#if defined(_WINDOWS) && defined(DEBUG)
2002-12-21 08:13:22 +00:00
MessageBox( NULL, error, "Fatal Error", MB_OK );
DebugBreak();
#endif
2003-12-21 21:34:01 +00:00
throw RageException( error );
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);
CString error = vssprintf( fmt, va );
va_end(va);
2002-12-21 08:13:22 +00:00
2003-12-21 21:34:01 +00:00
throw RageException( error );
2002-12-21 08:13:22 +00:00
}