mirror of https://github.com/PCSX2/pcsx2.git
common: make DESTRUCTOR_CATCHALL macro really exception safe
Console.Error() can trigger some exceptions (like out of memory) v2: Add a default fallback catch(...) in case someone badly add a new exception in the codebase
This commit is contained in:
parent
2eb73644e9
commit
927dd827ce
|
@ -29,16 +29,28 @@ void pxTrap();
|
||||||
// exception. Use this macro to dispose of these dangerous exceptions, and generate a
|
// exception. Use this macro to dispose of these dangerous exceptions, and generate a
|
||||||
// friendly error log in their wake.
|
// friendly error log in their wake.
|
||||||
//
|
//
|
||||||
|
// Note: Console can also fire an Exception::OutOfMemory
|
||||||
#define __DESTRUCTOR_CATCHALL( funcname ) \
|
#define __DESTRUCTOR_CATCHALL( funcname ) \
|
||||||
catch( BaseException& ex ) \
|
catch( BaseException& ex ) \
|
||||||
{ \
|
{ \
|
||||||
Console.Error( "Unhandled BaseException in %s (ignored!):", funcname ); \
|
try { \
|
||||||
Console.Error( ex.FormatDiagnosticMessage() ); \
|
Console.Error( "Unhandled BaseException in %s (ignored!):", funcname ); \
|
||||||
|
Console.Error( ex.FormatDiagnosticMessage() ); \
|
||||||
|
} catch (...) { \
|
||||||
|
fprintf(stderr, "ERROR: (out of memory?)\n"); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
catch( std::exception& ex ) \
|
catch( std::exception& ex ) \
|
||||||
{ \
|
{ \
|
||||||
Console.Error( "Unhandled std::exception in %s (ignored!):", funcname ); \
|
try { \
|
||||||
Console.Error( ex.what() ); \
|
Console.Error( "Unhandled std::exception in %s (ignored!):", funcname ); \
|
||||||
|
Console.Error( ex.what() ); \
|
||||||
|
} catch (...) { \
|
||||||
|
fprintf(stderr, "ERROR: (out of memory?)\n"); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
catch(...) { \
|
||||||
|
/* Unreachable code */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DESTRUCTOR_CATCHALL __DESTRUCTOR_CATCHALL( __pxFUNCTION__ )
|
#define DESTRUCTOR_CATCHALL __DESTRUCTOR_CATCHALL( __pxFUNCTION__ )
|
||||||
|
|
Loading…
Reference in New Issue