set exception handler inside the runtime
Posted: Wed Oct 20, 2021 2:18 pm
Hi Wolfgang,
One way would be to define an Event in the library, with information about the exception and intercept it from your core app. Something like:
Then just call ErrorHandler.LinkErrorBlock() to set the new error block and subscribe to the event in your core app, like with
.
One way would be to define an Event in the library, with information about the exception and intercept it from your core app. Something like:
Code: Select all
// in a VO dialect library:
DELEGATE ErrorHappenedDelegate(oError AS Exception) AS VOID
STATIC CLASS ErrorHandler
STATIC EVENT ErrorHappened AS ErrorHappenedDelegate
STATIC METHOD RaiseError(oError AS Exception) AS VOID
IF ErrorHandler.ErrorHappened != NULL
ErrorHandler.ErrorHappened(oError)
END IF
STATIC METHOD LinkErrorBlock() AS VOID
ErrorBlock({|oError| ErrorHandler.RaiseError(oError)})
END CLASS
Code: Select all
// in the main core app:
ErrorHandler.ErrorHappened += MyErrorHandler
PROCEDURE MyErrorHandler(oError AS Exception)
? oError:ToString()