You get this stack trace by invoking the Stack() method of the RuntimeException object you get passed in UnhandledException. For instance, if you send your built application to others who do not have the Xojo debugger, your program could still record the so-called stack trace from the exception, show that to the user, and ask him to forward that information to you so you can hopefully deduce what went wrong and how to avoid it in the future. One other use of this handler is to record the location where the exception occurred in order to use that for later debugging. It lets you catch any unhandled exceptions in your program, preventing your program from getting terminated unexpectedly, and allowing you to save any interim data that the user may have not saved yet, and other defensive fallback procedures. You probably know the UnhandledException event handler in the App class.
I hope this article will be helpful to both newcomers and veterans alike.īackground (UnhandledException and the Stack Trace) This post offers an introduction to the usefulness of exception handling in general, while also explaining how to deal with a particular shortcoming when you use debugging code and the UnhandledException event handler in built programs you deliver to people. (This is a repost of an article of mine on Real Software's, now Xojo Inc's, former blog )