madExcept change behavior of Exception.ToString.

delphi package - automated exception handling
Post Reply
benok
Posts: 3
Joined: Thu Oct 29, 2015 12:53 am

madExcept change behavior of Exception.ToString.

Post by benok »

Code: Select all

begin
  try
    try
      try
        StrToFloat('123.45.');
      except
        Exception.RaiseOuterException(Exception.Create('Failed to load some settings'));
      end;
    except
      Exception.RaiseOuterException(Exception.Create('Failed to load project file'));
    end;
  except
    on E: Exception do
      Writeln(E.ToString);
  end;
  Readln;
end.
Hi, I'm a commercial user of madExcept4.

I've started to use Exception.RaiseOuterException and Exception.ToString like above,
to give informative error message to app users.

This code gives error messages below.
"Failed to load project file
Failed to load some settings
'123.45.' is not a valid floating point value"

I used to concatenate Exception message by hand, but it's done by Exception.ToString automatically.
I think it's handy and seems good practice.

But with madExcept enabled, E.ToString gives "Failed to load project file" only. :(
Can you keep Exception's nested structure while madExcept hook being enabled ?

Could you fix this problem ?
benok
Posts: 3
Joined: Thu Oct 29, 2015 12:53 am

Re: madExcept change behavior of Exception.ToString.

Post by benok »

Hmm, it seems hard to fix, right ?
I'll rewrite back to hand chaining Exception message, at this time...
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: madExcept change behavior of Exception.ToString.

Post by madshi »

Sorry for the late reply.

This is not easy to fix because I've done a lot of tricks and hacks to automatically make nested/inner exceptions work even in older Delphi versions which don't officially support this functionality. Now you're using some newer RTL functions which aren't available in older Delphi versions, and which I've "ignored" up until now. So I'll have to double check all my code to see how I can implement support for that properly, without breaking functionality for older Delphi versions etc. So this is not really easy...
Post Reply