Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to catch unhandled application exceptions and log them

is there any way to catch and log all errors in application. In the moment I use try catch blocks in places where I think error can occur. But is there a possibility to catch all errors in application level (I mean, can I put try catch block to project file or maybe some other trick will do it)?

like image 746
evilone Avatar asked Feb 17 '11 18:02

evilone


3 Answers

You could also consider Eureka Log, which CodeGear themselves used for their PHP product. Eureka Log also has memory leak detection and allows you to have crash reports silently emailed, ftp'd, added to a bug tracking system automatically, or allows interactive crash dump submission.

enter image description here

It isn't free, but I think it is well worth the money. I honestly couldn't imagine using Delphi without it. Also, they have a .NET edition of the program as well.

One last feature that I love, is that you can actually configure the product to take different actions with certain exceptions, while still capturing others normally. I use this with some of the Indy exceptions that can be thrown:

enter image description here

like image 149
Mick Avatar answered Sep 27 '22 16:09

Mick


Take a look at MadExcept. If you add it into your project, it automatically installs hooks that will catch all unhandled exceptions, generate very informative error reports, and even email them to you or post them to a web service. It's the next best thing to actually being able to attach the debugger to your clients' systems.

like image 38
Mason Wheeler Avatar answered Sep 27 '22 17:09

Mason Wheeler


"Catching" an exception can mean many things: logging it, displaying it, acting on it, reraising it, or any combination of the above. The TApplication OnException handler will "catch" all unhandled main thread exceptions, but will not catch exceptions raised in threads. To do this you will need to implement your own thread exception handling. In my application framework (http://www.csinnovations.com/framework_overview.htm) I have code that will ensure that any exception can be logged (all unhandled exceptions and optionally any handled exceptions), and optionally displayed if it is in the main thread, regardless of whether it occurs in the main thread or any other thread. While it is not as comprehensive as MadExcept, it has all the functionality that is needed to handle exceptions.

like image 28
Misha Avatar answered Sep 27 '22 15:09

Misha