[fpc-pascal] Exceptions in Library
steveg
steveg at nevets.com.au
Tue Mar 31 00:50:19 CEST 2015
On 30/03/15 16:46, leledumbo wrote:
>> As far as I can tell, exceptions propagate through to the main app -
>> (written with Lazarus in this case).
>> I would like to trap them directly within the library.
> // excp.pas
> library excp;
>
> {$mode objfpc}
>
> uses sysutils;
>
> procedure p;
> begin
> try
> raise exception.create('an exception')
> except
> on e: exception do
> writeln(e.message);
> end;
> end;
>
> exports p;
>
> end.
>
> // test.pas
> procedure p; external 'excp';
>
> begin p end.
>
> run with:
> $ LD_LIBRARY_PATH=. ./test
>
> you should get:
> an exception
>
> tested on ManjaroLinux 64-bit.
>
Tested this, and you are correct - it captures it correctly
After further testing - It would seem to capture some but not others ?
(contrived example - I know not to directly call a control within a library)
this doesnt seem to be trapped - drops thru to main app
try
Str1 := TControl(0).Name;
except
on e: exception do
writeln(e.message);
end;
Would this suggest a different signal attachment is necessary ?
Thanks
More information about the fpc-pascal
mailing list