Add Engine::ReportCrash event for custom crash reporting or handling

This commit is contained in:
Wojtek Figat
2025-01-24 20:15:17 +01:00
parent cf40facefe
commit b36e55446f
3 changed files with 10 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ Action Engine::Draw;
Action Engine::Pause;
Action Engine::Unpause;
Action Engine::RequestingExit;
Delegate<StringView, void*> Engine::ReportCrash;
FatalErrorType Engine::FatalError = FatalErrorType::None;
bool Engine::IsRequestingExit = false;
int32 Engine::ExitCode = 0;

View File

@@ -83,6 +83,11 @@ public:
/// </summary>
API_EVENT() static Action RequestingExit;
/// <summary>
/// The custom handler for engine crash handling and reporting. Can be used to override default message box with a custom one or send crash report to telemetry service. Args are: error message and context pointer (for stack-trace access).
/// </summary>
API_EVENT() static Delegate<StringView, void*> ReportCrash;
/// <summary>
/// The current state of the fatal error. Set to None if no error occurred yet.
/// </summary>

View File

@@ -372,7 +372,10 @@ void PlatformBase::Fatal(const StringView& msg, void* context, FatalErrorType er
}
// Show error message
Error(msg);
if (Engine::ReportCrash.IsBinded())
Engine::ReportCrash(msg, context);
else
Error(msg);
// Only main thread can call exit directly
if (IsInMainThread())