mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fix ProtectedCall default handler
This commit is contained in:
@@ -277,9 +277,25 @@ bool CatchAny (Function <void (void)> f, bool returnFromException)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void ProtectedCall::DefaultHandler::onException (ProtectedCall::Exception const&) const
|
||||
class ProtectedCall::DefaultHandler : public Handler
|
||||
{
|
||||
}
|
||||
public:
|
||||
void onException (Exception const&) const
|
||||
{
|
||||
ScopedLockType lock (s_mutex);
|
||||
fatal_error ("An unhandled exception was thrown");
|
||||
}
|
||||
|
||||
private:
|
||||
typedef CriticalSection LockType;
|
||||
typedef CriticalSection::ScopedLockType ScopedLockType;
|
||||
|
||||
static LockType s_mutex;
|
||||
};
|
||||
|
||||
ProtectedCall::DefaultHandler::LockType ProtectedCall::DefaultHandler::s_mutex;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Static::Storage <Atomic <ProtectedCall::Handler const*>, ProtectedCall>
|
||||
ProtectedCall::s_handler;
|
||||
@@ -319,15 +335,19 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void testThrow ()
|
||||
{
|
||||
throw std::runtime_error ("uncaught exception");
|
||||
}
|
||||
|
||||
void runTest ()
|
||||
{
|
||||
beginTestCase ("backtrace");
|
||||
beginTestCase ("throw");
|
||||
|
||||
String const s = SystemStats::getStackBacktrace ();
|
||||
ProtectedCall (&ProtectedCallTests::testThrow, this);
|
||||
|
||||
logMessage (s);
|
||||
|
||||
pass ();
|
||||
// If we get here then we failed
|
||||
fail ();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
ProtectedCall (&funcThatMightThrow, 3);
|
||||
|
||||
@endcode
|
||||
|
||||
Every Beast Thread object's @ref Thread::run method is wrapped in a
|
||||
@ProtectedCall
|
||||
|
||||
@see Thread, Throw
|
||||
*/
|
||||
class ProtectedCall
|
||||
{
|
||||
@@ -60,10 +65,7 @@ public:
|
||||
};
|
||||
|
||||
/** The default handler writes to std::cerr makes the process exit. */
|
||||
class DefaultHandler : public Handler
|
||||
{
|
||||
void onException (Exception const& e) const;
|
||||
};
|
||||
class DefaultHandler;
|
||||
|
||||
static void setHandler (Handler const& handler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user