mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add ripple::FatalErrorReporter
This commit is contained in:
55
modules/ripple_app/main/ripple_FatalErrorReporter.cpp
Normal file
55
modules/ripple_app/main/ripple_FatalErrorReporter.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (c) 2011-2013, OpenCoin, Inc.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
FatalErrorReporter::FatalErrorReporter ()
|
||||
{
|
||||
FatalError::setReporter (*this);
|
||||
}
|
||||
|
||||
FatalErrorReporter::~FatalErrorReporter ()
|
||||
{
|
||||
FatalError::resetReporter (*this);
|
||||
}
|
||||
|
||||
void FatalErrorReporter::onFatalError (
|
||||
char const* message,
|
||||
char const* stackBacktrace,
|
||||
char const* fileName,
|
||||
int lineNumber)
|
||||
{
|
||||
String s;
|
||||
|
||||
s << "Message = '" << message << "'" << newLine;
|
||||
s << "File = '" << fileName << "' Line " << String (lineNumber) << newLine;
|
||||
s << "Stack Trace:" << newLine;
|
||||
s << stackBacktrace;
|
||||
|
||||
Log::out() << s;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class FatalErrorReporterTests : public UnitTest
|
||||
{
|
||||
public:
|
||||
FatalErrorReporterTests () : UnitTest ("FatalErrorReporter", "ripple", runManual)
|
||||
{
|
||||
}
|
||||
|
||||
void runTest ()
|
||||
{
|
||||
beginTestCase ("report");
|
||||
|
||||
FatalErrorReporter reporter;
|
||||
|
||||
// We don't really expect the program to run after this
|
||||
// but the unit test is here so you can manually test it.
|
||||
|
||||
FatalError ("unit test", __FILE__, __LINE__);
|
||||
}
|
||||
};
|
||||
|
||||
static FatalErrorReporterTests fatalErrorReporterTests;
|
||||
Reference in New Issue
Block a user