Delphi general exception catch

delphi, exception

Solution

You can attach an eventhandler to `Application.OnException` and handle any unhandled exception there.

Depending on your Delphi version, you can either

- attach and implement an eventhandler entirely in code in your Main Form, dpr or wherever you see fit in the form of `Application.OnException := DoApplicationException`.

- drop a `TApplicationEvents` component on your main form, double click the OnException event and implement your code.

Problem

In .NET WinForms there is a such tip that I can catch any uncatched exception on the application level. Could it can be done also in Delphi - in the case that the source of the exception can't be bound with try/except block.

Original source

Related problems