Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-11

Catching Exceptions in Library

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Steve Gatenby

Could anybody tell me why the following error is caught by the try except in an Application, but not in a Library ?

I am needing to find out where try except doesn't do what I think, not fix this code.

this is a contrived error to show the problem, not part of my code :)

procedure Test();
var
   Ctrl    :TObject;
begin
   try
     Ctrl  := TObject(12345);
     sStr1 := Ctrl.ClassName;
   except
     writeln('Caught Exception');
   end;
end;

Thanks - SteveG

waldo kitty
to Steve Gatenby
Steve Gatenby wrote 5 lines
Could anybody tell me why the following error is caught by the try except in an Application, but not in a Library ? I am needing to find out where try except doesn't do what I think, not fix this code.

are you seeing a different error than what you are expecting? if so, it is possible that it is triggered elsewhere in your code and not caught there...

NOTE: No off-list assistance is given without prior approval. Please *keep mailing list traffic on the list* unless private contact is specifically requested and granted.
Steve Gatenby
to waldo kitty
waldo kitty wrote 13 lines
On 11/6/2014 7:39 PM, Steve Gatenby wrote: > Could anybody tell me why the following error is caught by the try > except in an > Application, but not in a Library ? > > I am needing to find out where try except doesn't do what I think, > not fix this > code. are you seeing a different error than what you are expecting? if so, it is possible that it is triggered elsewhere in your code and not caught there...

As far as I can tell, it falls thru (or back to) the application and is caught there.
The problem is if you have a function 'chain' - F1 (app) calls F2 (lib) calls F3 (lib) etc
If not caught in the failing function, its impossible to tell at which step it failed

Sven Barth
to Steve Gatenby: Could anybody tell me why the following error is caught by the try except in an…
Steve Gatenby wrote 7 lines
Could anybody tell me why the following error is caught by the try except in an Application, but not in a Library ? I am needing to find out where try except doesn't do what I think, not fix this code. this is a contrived error to show the problem, not part of my code :)

Which platform and OS and which compiler version?

If you use 2.6.x and Win64 or Win32 then please test with 2.7.1 (for 32-Bit: please pass OPT="-dTEST_WIN32_SEH" to make).

Regards,
Sven

Steve Gatenby
to Sven Barth
Sven Barth wrote 17 lines
On 07.11.2014 01:39, Steve Gatenby wrote: > Could anybody tell me why the following error is caught by the try > except in an Application, but not in a Library ? > > I am needing to find out where try except doesn't do what I think, not > fix this code. > > this is a contrived error to show the problem, not part of my code :) Which platform and OS and which compiler version? If you use 2.6.x and Win64 or Win32 then please test with 2.7.1 (for 32-Bit: please pass OPT="-dTEST_WIN32_SEH" to make). Regards, Sven

Sorry, forgot to supply it -
Lazarus 1.3 r46685M FPC 2.6.2 i386-linux-gtk 2