DesktopApplication.UnhandledException

From Xojo Documentation

Revision as of 15:33, 25 January 2022 by Gperlman (talk | contribs) (Sample code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Event


DesktopApplication.UnhandledException(error As RuntimeException) As Boolean

New in 2021r3

Supported for all project types and targets.

If a RuntimeException is not caught anywhere else (using Exception or Try...Catch), this event is called so you may handle the exception. Return True to suppress the quit behavior. Return False to use the default quit behavior.

Notes

If a RuntimeException is not caught anywhere else, this event is called so you may handle the exception. See the example.

Sample code

This code in the UnhandledException event of the App class catches any unhanded exceptions and displays the name of the exception along with the error stack:

If error <> Nil Then
Var type As String = Introspection.GetType(error).Name
MessageBox(type + EndOfLine + EndOfLine + String.FromArray(error.Stack, EndOfLine))
End If