How to report AV or other fatals from within try...except?

delphi package - automated exception handling
Post Reply
amr
Posts: 6
Joined: Sat Mar 25, 2006 1:51 pm

How to report AV or other fatals from within try...except?

Post by amr »

Hi,

I'm now looking for an extended exception reporting component, and so far madExcept looks just perfect. However, I have a question:

In my app there are some threads that load data from a database and expect to get and handle various kinds of DB-related exceptions, so all the dangerous stuff is inside Try..Except blocks. However, if something like an AV or zero divide happens, it has to be due to a bug in the program and must be immediately reported, rather than left to the program to handle.

Q: Is there any [easy] way to configure madExcept so that it would show its dialog and send report on AVs and other fatal exceptions (basically, on any exception object derived from EExternal), even though they happen inside a TRY...EXCEPT block?

If there is no way to do so without changing the code, what should I call in the EXCEPT section to trigger madExcept's error dialog ?

Regards,

Alex Rytov,
AdeptSQL Tools
madshi
Site Admin
Posts: 10765
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You can do something like this:

Code: Select all

procedure RaiseEExternal(const exceptIntf: IMEException; var handled: boolean);
begin
  if (exceptIntf.ExceptObject <> nil) and
     (exceptIntf.ExceptObject is EExternal) then
    handled := false;
end;

initialization
  RegisterHiddenExceptionHandler(RaiseEExternal, stDontSync);
Your "RaiseEExternal" handler will be called for any exception which gets "eaten" by a try..except statement. If you set "handled := false" in that handler, madExcept will get active.
amr
Posts: 6
Joined: Sat Mar 25, 2006 1:51 pm

Post by amr »

Thanks for the lightning-fast response!

I found that I could do what I needed by adding

"on EExternal" do raise;"

clause into one specific try..except, but the way with Hidden handlers is obviously better.

BTW, if I have a Beta version of a commercial product with your exception reporting inside, do I need a commercial licence? If I do, can I pay through ShareIt V2V transfer rather than through the order page?
madshi
Site Admin
Posts: 10765
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

amr wrote:I found that I could do what I needed by adding

"on EExternal" do raise;"

clause into one specific try..except
Yeah, possible, but you'd need it to every try..except statement, of course.

P.S: Or if you can really get it solved by adding it into one try..except block only, then actually I'd recommend doing this instead of using the hidden handler stuff. Why? Because the hidden handler stuff is based on some ugly hacking, while this reraise is clean and documented.
amr wrote:BTW, if I have a Beta version of a commercial product with your exception reporting inside, do I need a commercial licence? If I do, can I pay through ShareIt V2V transfer rather than through the order page?
As long as you don't earn money with that product yet, you don't need to buy a license yet. Generally payment through V2V should be possible, but I've never done it before, so I don't know how it works... :D
amr
Posts: 6
Joined: Sat Mar 25, 2006 1:51 pm

Post by amr »

Re purchase: [Answered by email]
Post Reply