Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi general exception catch

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.

like image 587
DreadAngel Avatar asked May 13 '12 17:05

DreadAngel


1 Answers

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.
like image 130
Lieven Keersmaekers Avatar answered Oct 19 '22 12:10

Lieven Keersmaekers