> 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.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Exceptions-in-Library-tp5721521p5721522.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to