Page 1 of 2
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 9:42 am
by wriedmann
Hello Robert or Chris,
how do I set an my own error handler inside the X# runtime (specifically the RDD) when using a Core dialect application?
To specify it better: I have a command line X# application that is called by the task scheduler in Windows and does something.
Therefore, when en exception occurs, no messagebox can be shown, but an email should be sent using a personalized exception handler.
The application is written in Core dialect and is using a VO dialect library to access DBF files.
Thank you very much!
Wolfgang
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 10:28 am
by ic2
Hello Wolfgang,
At the end of the last session
https://www.youtube.com/watch?v=qvbqxGt0zgQ I understood that a preprocessor script could take over global error handling (a bit like Ralph's error classes can do for VO).
On Robert's (large) to do list there is the promise that he will post a sample to do so, after my question.
Maybe that sample answers your question?
Dick
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 10:30 am
by ic2
Has everyone noticed that in the YouTube screenshot Robert looks like a pirate, with the Play icon on his left eye?
Dick
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 10:53 am
by wriedmann
Hi Dick,
yes, I looked at that session on Youtube, but unfortunately it does not answers my question.
I already have an exception handler active in my application, but it is not called if any exception occurs inside the RDD classes.
So there must be any functionality to set an own error handler in the RDD classes.
Wolfgang
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 11:35 am
by Chris
Hi Wolfgang,
You can just use ErrorBlock() and provide your own error handling. Something like
ErrorBlock({|oError| MyErrorHandler(oError)})
PROCEDURE MyErrorHandler(oError AS Exception)
? oError:ToString()
If your main exe is in Core and it does not know about codeblocks etc, you can do this in teh VO dialect library instead.
.
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 11:43 am
by wriedmann
Hi Chris,
thank you very much, I will try that.
Wolfgang
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 1:56 pm
by wriedmann
Hi Chris,
maybe I'm stupid and don't see the wood because of the trees: but how I can do that?
My application is in Core dialect and does not knows about codeblocks, but the DLL knows about it (being in VO dialect).
But in case of an error e method of the main (Core dialect) application should be called.
How can I convert a function pointer passed from the application to a codeblock?
Wolfgang
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 2:02 pm
by Meinhard
Hi Wolfgang,
I strongly recommend to look into MS Enterprise Library Exception Handling Block. The secret is to have different policies, depending on the environment, which actually handle the exception, without the need to handle this in your code, as you can incluence the setup of the exception handling by configuration.
Regards
Meinhard
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 2:06 pm
by wriedmann
Hi Meinhard,
I already have my error handlers in place.
My problem is how to make the X# runtime call my Core dialect error handler when there is a runtime error inside the X# runtime (specifically in the RDD).
Wolfgang
set exception handler inside the runtime
Posted: Wed Oct 20, 2021 2:12 pm
by wriedmann
Hi Chris,
I think, I have found it (at least it works).
In my VO dialect library I have that static method:
Code: Select all
static method SetExceptionHandler( oObject as object, cMethodName as string ) as void
ErrorBlock( {|o| Send( oObject, String2Symbol( cMethodName ), o ), _Break( o ) } )
return
and the relative call is that here:
Code: Select all
rdm.XbaseInterface.VOInterface.SetExceptionHandler( self, "ProcessExceptionRT" )
whereas the called method is this one:
Code: Select all
method ProcessExceptionRT( oEx as Exception ) as void
self:WriteLog( oEx:Message )
self:WriteLog( oEx:StackTrace )
self:SendMail( "Fehler in BNBatchProcessor aufgetreten", oEx:Message, ProgSettings.ErrorMailTo, false )
return
Wolfgang