* use reference to for exception handlers

This commit is contained in:
michael 2020-05-18 07:40:35 +00:00
parent d9238eb798
commit 27b6f1c5a3
2 changed files with 6 additions and 5 deletions

View File

@ -65,7 +65,7 @@ Procedure TErrorApp.Run;
begin
// This will only work for the main program if you have set showUncaughtExceptions before rtl.run();
// TJSHtmlButtonElement(Document.getElementById('btnhook')).OnClick:=@DoHook;
TJSHtmlButtonElement(Document.getElementById('btnhook')).OnClick:=@DoHook;
// These will not be caught (yet)
TJSHtmlButtonElement(Document.getElementById('btn')).OnClick:=@DoRaise;
// Uncomment this to set default exception handlers
@ -73,7 +73,7 @@ begin
// Uncomment these to set special exception handlers
// SetOnUnCaughtExceptionHandler(@DoPascalException);
// SetOnUnCaughtExceptionHandler(@DoJSException);
SetOnUnCaughtExceptionHandler(@DoJSException);
// Various ways to raise an exception.
// DoRaiseJS;

View File

@ -315,8 +315,8 @@ type
TOnGetEnvironmentString = function(Index: Integer): String;
TOnGetEnvironmentVariableCount = function: Integer;
TShowExceptionHandler = Procedure (Const Msg : String);
TUncaughtPascalExceptionHandler = Procedure(aObject : TObject);
TUncaughtJSExceptionHandler = Procedure(aObject : TJSObject);
TUncaughtPascalExceptionHandler = reference to Procedure(aObject : TObject);
TUncaughtJSExceptionHandler = reference to Procedure(aObject : TJSObject);
var
OnGetEnvironmentVariable: TOnGetEnvironmentVariable;
@ -326,10 +326,11 @@ var
OnShowException : TShowExceptionHandler = nil;
// Set handlers for uncaught exceptions. These will call HookUncaughtExceptions
// They return the old exception handler, if there was any.
Function SetOnUnCaughtExceptionHandler(aValue : TUncaughtPascalExceptionHandler) : TUncaughtPascalExceptionHandler;
Function SetOnUnCaughtExceptionHandler(aValue : TUncaughtJSExceptionHandler) : TUncaughtJSExceptionHandler;
// Hook the rtl handler for uncaught exceptions. If any exception handlers were set, they will be called.
// If none was set, the exceptions will be displayed using ShowException.
// If none were set, the exceptions will be displayed using ShowException.
Procedure HookUncaughtExceptions;
function GetEnvironmentVariable(Const EnvVar: String): String;