Add a central assert handler that generates sentry events
This commit is contained in:
parent
c2d56eefb9
commit
8eb265bf4c
|
@ -916,3 +916,35 @@ void PGM_BASE::HandleException( std::exception_ptr aPtr )
|
|||
wxLogError( wxT( "Unhandled exception of unknown type" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PGM_BASE::HandleAssert( const wxString& aFile, int aLine, const wxString& aFunc,
|
||||
const wxString& aCond, const wxString& aMsg )
|
||||
{
|
||||
wxString assertStr;
|
||||
// Log the assertion details to standard log
|
||||
if( !aMsg.empty() )
|
||||
{
|
||||
assertStr = wxString::Format( "Assertion failed at %s:%d in %s: %s - %s", aFile, aLine,
|
||||
aFunc, aCond, aMsg );
|
||||
}
|
||||
else
|
||||
{
|
||||
assertStr = wxString::Format( "Assertion failed at %s:%d in %s: %s", aFile, aLine, aFunc,
|
||||
aCond );
|
||||
}
|
||||
|
||||
wxLogError( assertStr );
|
||||
|
||||
#ifdef KICAD_USE_SENTRY
|
||||
if( Pgm().IsSentryOptedIn() )
|
||||
{
|
||||
sentry_value_t exc = sentry_value_new_exception( "assert", assertStr );
|
||||
sentry_value_set_stacktrace( exc, NULL, 0 );
|
||||
|
||||
sentry_value_t sentryEvent = sentry_value_new_event();
|
||||
sentry_event_add_exception( sentryEvent, exc );
|
||||
sentry_capture_event( sentryEvent );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -140,17 +140,7 @@ void CustomAssertHandler(const wxString& file,
|
|||
const wxString& cond,
|
||||
const wxString& msg)
|
||||
{
|
||||
// Log the assertion details to standard log
|
||||
if (!msg.empty())
|
||||
{
|
||||
wxLogError( "Assertion failed at %s:%d in %s: %s - %s",
|
||||
file, line, func, cond, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogError( "Assertion failed at %s:%d in %s: %s",
|
||||
file, line, func, cond);
|
||||
}
|
||||
Pgm().HandleAssert( file, line, func, cond, msg );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -323,7 +323,7 @@ public:
|
|||
#endif
|
||||
|
||||
/**
|
||||
* A excepion handler to be used at the top level if exceptions bubble up that for
|
||||
* A exception handler to be used at the top level if exceptions bubble up that for
|
||||
*
|
||||
* The purpose is to have a central place to log a wxWidgets error message and/or sentry report
|
||||
*
|
||||
|
@ -331,6 +331,20 @@ public:
|
|||
*/
|
||||
void HandleException( std::exception_ptr aPtr );
|
||||
|
||||
/**
|
||||
* A common assert handler to be used between single_top and kicad
|
||||
*
|
||||
* This lets us have a common set of assert handling, including triggering sentry reports
|
||||
*
|
||||
* @param aFile the file path of the assert
|
||||
* @param aLine the line number of the assert
|
||||
* @param aFunc the function name the assert is within
|
||||
* @param aCond the condition of the assert
|
||||
* @param aMsg the attached assert message (can be empty)
|
||||
*/
|
||||
void HandleAssert( const wxString& aFile, int aLine, const wxString& aFunc,
|
||||
const wxString& aCond, const wxString& aMsg );
|
||||
|
||||
/**
|
||||
* Determine if the application is running with a GUI
|
||||
*
|
||||
|
|
|
@ -414,17 +414,7 @@ void CustomAssertHandler(const wxString& file,
|
|||
const wxString& cond,
|
||||
const wxString& msg)
|
||||
{
|
||||
// Log the assertion details to standard log
|
||||
if (!msg.empty())
|
||||
{
|
||||
wxLogError( "Assertion failed at %s:%d in %s: %s - %s",
|
||||
file, line, func, cond, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogError( "Assertion failed at %s:%d in %s: %s",
|
||||
file, line, func, cond);
|
||||
}
|
||||
Pgm().HandleAssert( file, line, func, cond, msg );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue