Limits of OnErrorCall
Posted: Wed Jul 16, 2025 5:15 pm
I have an application that crashes, as in completely disappears with no errors, no warning, even though I have OnErrorCall() in place. I was hoping OnErrorCall allowed for unexpected errors to be trapped in a handler so I could do a graceful exit and log the event.
The application creates a PDF report. I had an accidental situation where a bad filename could be supplied to PdfVectorOutput(), causing StartVectorDrawing() to then fail. After that a call to VectorFont() causes the entire program to crash with no warning. (Yes, yes, I was checking result of StartVectorDrawing, and it was a mistake on my part that the program was continuing to render the report.)
But a bad filename, or hard drive full, or a networking error, these are all good examples of situations that could arise unexpectedly, and I assumed that as a worst case an error handler would allow the event to be logged, so that the root cause could be fixed.
So... why does the following OnErrorCall example not work, and what exactly are the limits to what type of errors can be trapped?
(I compiled below to an .exe on Windows 10, PB 6.12 with "Enable Debugger" unchecked in compiler options.)
Thanks
The application creates a PDF report. I had an accidental situation where a bad filename could be supplied to PdfVectorOutput(), causing StartVectorDrawing() to then fail. After that a call to VectorFont() causes the entire program to crash with no warning. (Yes, yes, I was checking result of StartVectorDrawing, and it was a mistake on my part that the program was continuing to render the report.)
But a bad filename, or hard drive full, or a networking error, these are all good examples of situations that could arise unexpectedly, and I assumed that as a worst case an error handler would allow the event to be logged, so that the root cause could be fixed.
So... why does the following OnErrorCall example not work, and what exactly are the limits to what type of errors can be trapped?
(I compiled below to an .exe on Windows 10, PB 6.12 with "Enable Debugger" unchecked in compiler options.)
Code: Select all
Procedure VectorErrorOnPurpose()
LoadFont(0,"Times New Roman",20)
VectorFont(FontID(0),18)
EndProcedure
Procedure ErrorHandler()
MessageRequester("test","Error trapped successfully!")
EndProcedure
MessageRequester("test","Enable Error trapping")
OnErrorCall(@ErrorHandler())
MessageRequester("test","Causing error...")
VectorErrorOnPurpose()
MessageRequester("test","Should never see this!")