Stack trace question (newbie)

delphi package - automated exception handling
Post Reply
Adrien Reboisson
Posts: 4
Joined: Sat Feb 18, 2006 9:46 am
Location: France

Stack trace question (newbie)

Post by Adrien Reboisson »

Hi Mathias !

I'm new to madExcept and I don't know if your package allow me to do what I want... I have designed a multi-threaded console server application which is connected to a database. Sometimes, exceptions are raised by the database driver... As I used a lot of try..finally...end / try...except...end code patterns, exceptions are handled correctly and error messages are displayed on the console, but to be able to decide if something goes really wrong in my code I have to know which function has raised the exception. In a nutshell, I need a stack trace.

I know that madExcept can do that, but the real matter is "how to call the function which generates the stack trace". Should I modify all my try..except...blocks in order to call the function which creates the stack trace in order to display it on the user's screen ?

Is there a mean to call a generic function *each time* an exception is raised in order to display the stack trace ? A kind of proc which would be called prior to all "except" or "finally" events handlers of my application... For instance, I cannot use MadExceptionHandler.OnException since exceptions are caught inside the try/except/blocks.

Hope I have been clear enough ;-)

Best regards,

A.R.
Grey
Posts: 2
Joined: Sun Feb 19, 2006 11:30 pm

Post by Grey »

I too would love to be able to do this - it would allow us to integrate madExcept into our common logging framework and write a stack trace/bug report for every single exception raised, whether it was trapped or not.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You have 3 choices:

(1) Either manually invoke madExcept in every try..except statement.
(2) Or redesign your exception management to use less try..except blocks.
(3) Or use "RegisterHiddenExceptionHandler".

http://help.madshi.net/madExceptUnit.ht ... ionHandler

Please note that calculating a stack trace does cost some time. So if your program raises exceptions very often, calculating a stack trace everytime will slow your program down.
Adrien Reboisson
Posts: 4
Joined: Sat Feb 18, 2006 9:46 am
Location: France

Post by Adrien Reboisson »

use "RegisterHiddenExceptionHandler".
Mhhh... Exactly what I searched for. Thank you very much !

Best regards,

A.R.
Post Reply