exceptions
This commit is contained in:
@@ -4,20 +4,12 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "StepMania.h"
|
#include "StepMania.h"
|
||||||
|
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
#if defined(_WINDOWS) && defined(DEBUG)
|
#if defined(_WINDOWS) && defined(DEBUG)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RageException::RageException( const CString &str ):
|
|
||||||
m_sError(str)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* RageException::what() const throw ()
|
|
||||||
{
|
|
||||||
return m_sError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is no longer actually implemented by throwing an exception, but it acts
|
/* This is no longer actually implemented by throwing an exception, but it acts
|
||||||
* the same way to code in practice. */
|
* the same way to code in practice. */
|
||||||
void RageException::Throw(const char *fmt, ...)
|
void RageException::Throw(const char *fmt, ...)
|
||||||
@@ -52,15 +44,6 @@ void RageException::Throw(const char *fmt, ...)
|
|||||||
HandleException( error );
|
HandleException( error );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageException::ThrowNonfatal(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list va;
|
|
||||||
va_start(va, fmt);
|
|
||||||
CString error = vssprintf( fmt, va );
|
|
||||||
va_end(va);
|
|
||||||
|
|
||||||
throw RageException( error );
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2004 Chris Danford
|
* Copyright (c) 2001-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -5,25 +5,9 @@
|
|||||||
#ifndef RAGEEXCEPTION_H
|
#ifndef RAGEEXCEPTION_H
|
||||||
#define RAGEEXCEPTION_H
|
#define RAGEEXCEPTION_H
|
||||||
|
|
||||||
#include <exception>
|
namespace RageException
|
||||||
#include <cstdarg>
|
|
||||||
|
|
||||||
class RageException : public exception
|
|
||||||
{
|
{
|
||||||
public:
|
void NORETURN Throw(const char *fmt, ...);
|
||||||
RageException( const CString &str );
|
|
||||||
|
|
||||||
virtual const char *what() const throw();
|
|
||||||
virtual ~RageException() throw() { }
|
|
||||||
|
|
||||||
/* The only difference between these is that Throw 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 void NORETURN Throw(const char *fmt, ...);
|
|
||||||
static void NORETURN ThrowNonfatal(const char *fmt, ...);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
CString m_sError;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ RageSoundDriver *MakeRageSoundDriver(CString drivers)
|
|||||||
|
|
||||||
for(unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i)
|
for(unsigned i = 0; ret == NULL && i < DriversToTry.size(); ++i)
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
Driver = DriversToTry[i];
|
Driver = DriversToTry[i];
|
||||||
LOG->Trace("Initializing driver: %s", DriversToTry[i].c_str());
|
LOG->Trace("Initializing driver: %s", DriversToTry[i].c_str());
|
||||||
|
|
||||||
@@ -150,9 +149,6 @@ RageSoundDriver *MakeRageSoundDriver(CString drivers)
|
|||||||
LOG->Info( "Couldn't load driver %s: %s", DriversToTry[i].c_str(), sError.c_str() );
|
LOG->Info( "Couldn't load driver %s: %s", DriversToTry[i].c_str(), sError.c_str() );
|
||||||
SAFE_DELETE( ret );
|
SAFE_DELETE( ret );
|
||||||
}
|
}
|
||||||
} catch(const RageException &e) {
|
|
||||||
LOG->Info("Couldn't load driver %s: %s", DriversToTry[i].c_str(), e.what());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ret)
|
if(ret)
|
||||||
|
|||||||
Reference in New Issue
Block a user