mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 00:09:26 +02:00
* Install error handler to examine exceptions during callback
This commit is contained in:
parent
9e0b2869a3
commit
45ec51dc1f
@ -1335,6 +1335,15 @@ function __job_create_object(
|
|||||||
function JOBCallback(const Func: TJOBCallback; Data, Code: Pointer; Args: PByte): PByte;
|
function JOBCallback(const Func: TJOBCallback; Data, Code: Pointer; Args: PByte): PByte;
|
||||||
function VarRecToJSValue(const V: TVarRec): TJOB_JSValue;
|
function VarRecToJSValue(const V: TVarRec): TJOB_JSValue;
|
||||||
|
|
||||||
|
Type
|
||||||
|
TJobCallbackErrorEvent = Procedure (E : Exception; M : TMethod; H : TJobCallbackHelper; Var ReRaise : Boolean) of Object;
|
||||||
|
TJobCallBackErrorCallback = Procedure (E : Exception; M : TMethod; H : TJobCallbackHelper; Var ReRaise : Boolean);
|
||||||
|
|
||||||
|
var
|
||||||
|
JobCallbackErrorHandler : TJobCallbackErrorEvent;
|
||||||
|
JobCallbackErrorCallBack : TJobCallBackErrorCallback;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -1390,8 +1399,11 @@ function JOBCallback(const Func: TJOBCallback; Data, Code: Pointer; Args: PByte
|
|||||||
var
|
var
|
||||||
m: TMethod;
|
m: TMethod;
|
||||||
h: TJOBCallbackHelper;
|
h: TJOBCallbackHelper;
|
||||||
|
reraise : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
|
try
|
||||||
try
|
try
|
||||||
{$IFDEF VERBOSEJOB}
|
{$IFDEF VERBOSEJOB}
|
||||||
writeln('In JOBCallback');
|
writeln('In JOBCallback');
|
||||||
@ -1400,6 +1412,21 @@ begin
|
|||||||
m.Code:=Code;
|
m.Code:=Code;
|
||||||
h.Init(Args);
|
h.Init(Args);
|
||||||
Result:=Func(m,h);
|
Result:=Func(m,h);
|
||||||
|
except
|
||||||
|
On E : Exception do
|
||||||
|
begin
|
||||||
|
{$IFDEF VERBOSEJOB}
|
||||||
|
writeln('In JOBCallback: caught exception ',E.ClassName,': ',E.Message);
|
||||||
|
{$ENDIF}
|
||||||
|
ReRaise:=True;
|
||||||
|
If Assigned(JobCallbackErrorHandler) then
|
||||||
|
JobCallbackErrorHandler(E,M,H,ReRaise)
|
||||||
|
else If Assigned(JobCallbackErrorCallback) then
|
||||||
|
JobCallbackErrorCallback(E,M,H,ReRaise);
|
||||||
|
if ReRaise then
|
||||||
|
Raise;
|
||||||
|
end
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
if Args<>nil then
|
if Args<>nil then
|
||||||
FreeMem(Args);
|
FreeMem(Args);
|
||||||
|
Loading…
Reference in New Issue
Block a user