Guard the new sentry calls because it won't be initialized if opted out

This commit is contained in:
Marek Roszko 2023-04-20 23:05:06 -04:00
parent 5b5176f104
commit 53ad203028
2 changed files with 36 additions and 21 deletions

View File

@ -234,11 +234,12 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
} }
} }
wxString msg;
#ifdef KICAD_WIN32_VERIFY_CODESIGN #ifdef KICAD_WIN32_VERIFY_CODESIGN
bool codeSignOk = KIPLATFORM::ENV::VerifyFileSignature( dname ); bool codeSignOk = KIPLATFORM::ENV::VerifyFileSignature( dname );
if( !codeSignOk ) if( !codeSignOk )
{ {
wxString msg;
msg.Printf( _( "Failed to verify kiface library '%s' signature." ), dname ); msg.Printf( _( "Failed to verify kiface library '%s' signature." ), dname );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
@ -261,11 +262,14 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
setlocale( lc_new_type, user_locale.c_str() ); setlocale( lc_new_type, user_locale.c_str() );
#ifdef KICAD_USE_SENTRY #ifdef KICAD_USE_SENTRY
wxString msg = wxString::Format( "Loading kiface %d", aFaceId ); if( Pgm().IsSentryOptedIn() )
sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() ); {
sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.kiface" ) ); msg = wxString::Format( "Loading kiface %d", aFaceId );
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) ); sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
sentry_add_breadcrumb( crumb ); sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.kiface" ) );
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
sentry_add_breadcrumb( crumb );
}
#endif #endif
if( !success ) if( !success )
@ -449,11 +453,15 @@ KIWAY_PLAYER* KIWAY::Player( FRAME_T aFrameType, bool doCreate, wxTopLevelWindow
try try
{ {
#ifdef KICAD_USE_SENTRY #ifdef KICAD_USE_SENTRY
wxString msg = wxString::Format( "Creating window type %d", aFrameType ); if( Pgm().IsSentryOptedIn() )
sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() ); {
sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.player" ) ); wxString msg = wxString::Format( "Creating window type %d", aFrameType );
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) ); sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
sentry_add_breadcrumb( crumb ); sentry_value_set_by_key( crumb, "category",
sentry_value_new_string( "kiway.player" ) );
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
sentry_add_breadcrumb( crumb );
}
#endif #endif
FACE_T face_type = KifaceType( aFrameType ); FACE_T face_type = KifaceType( aFrameType );
@ -504,11 +512,15 @@ bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
return true; return true;
#ifdef KICAD_USE_SENTRY #ifdef KICAD_USE_SENTRY
wxString msg = wxString::Format( "Closing window type %d", aFrameType ); if( Pgm().IsSentryOptedIn() )
sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() ); {
sentry_value_set_by_key( crumb, "category", sentry_value_new_string( "kiway.playerclose" ) ); wxString msg = wxString::Format( "Closing window type %d", aFrameType );
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) ); sentry_value_t crumb = sentry_value_new_breadcrumb( "navigation", msg.utf8_str() );
sentry_add_breadcrumb( crumb ); sentry_value_set_by_key( crumb, "category",
sentry_value_new_string( "kiway.playerclose" ) );
sentry_value_set_by_key( crumb, "level", sentry_value_new_string( "info" ) );
sentry_add_breadcrumb( crumb );
}
#endif #endif
if( frame->NonUserClose( doForce ) ) if( frame->NonUserClose( doForce ) )

View File

@ -898,12 +898,15 @@ void PGM_BASE::HandleException( std::exception_ptr aPtr )
catch( const std::exception& e ) catch( const std::exception& e )
{ {
#ifdef KICAD_USE_SENTRY #ifdef KICAD_USE_SENTRY
sentry_value_t exc = sentry_value_new_exception( "exception", e.what() ); if( Pgm().IsSentryOptedIn() )
sentry_value_set_stacktrace( exc, NULL, 0 ); {
sentry_value_t exc = sentry_value_new_exception( "exception", e.what() );
sentry_value_set_stacktrace( exc, NULL, 0 );
sentry_value_t sentryEvent = sentry_value_new_event(); sentry_value_t sentryEvent = sentry_value_new_event();
sentry_event_add_exception( sentryEvent, exc ); sentry_event_add_exception( sentryEvent, exc );
sentry_capture_event( sentryEvent ); sentry_capture_event( sentryEvent );
}
#endif #endif
wxLogError( wxT( "Unhandled exception class: %s what: %s" ), wxLogError( wxT( "Unhandled exception class: %s what: %s" ),