Page 1 of 1
How to use RaiseOnError?
Posted: Sat Nov 17, 2012 3:22 am
by jap
Hello,
I can't get custom error handling to work. I have the following line at the beginning of my source code:
RaiseOnError( p_MyError )
And later the p_MyError function, which displays my error message with the SystemRequest function.
When an error occurs (I cause the error by calling a function which doesn't exist), I get the standard Hollywood error message instead of my own message. What am I doing wrong?
Re: How to use RaiseOnError?
Posted: Sat Nov 17, 2012 3:56 am
by PEB
Place
RaiseOnError() AFTER your p_MyError().
Re: How to use RaiseOnError?
Posted: Sat Nov 17, 2012 7:16 pm
by jap
Didn't help

I still get the build in Hollywood error message.
Re: How to use RaiseOnError?
Posted: Sat Nov 17, 2012 10:01 pm
by jap
Here is my test program:
Code: Select all
Function p_MyError ( code, message$, command$, line )
DebugPrint ( "Code : ", code )
DebugPrint ( "Message: ", message$ )
DebugPrint ( "Command: ", command$ )
DebugPrint ( "Line : ", line )
EndFunction
RaiseOnError ( p_MyError )
/* Cause an error */
a = 1 / 0
WaitLeftMouse ()
When executed, it just pops up Hollywood's build in error message.
Re: How to use RaiseOnError?
Posted: Sat Nov 17, 2012 10:13 pm
by PEB
You are correct, that particular error does not seem to work with
RaiseOnError().
The rest of your code looks good; so if you replace a=1/0 with something like LoadBrush(1, ""), you will see
RaiseOnError() work as it should.
Re: How to use RaiseOnError?
Posted: Sun Nov 18, 2012 4:49 am
by jap
Thanks PEB. I think I'll just disable Hollywood's error handler with ExitOnError ( False ). I was trying to make my program to close quietly when error occurs, but it looks like it cannot be done.
Re: How to use RaiseOnError?
Posted: Sun Nov 18, 2012 12:00 pm
by airsoftsoftwair
Currently,
RaiseOnError() can only catch errors that are thrown by Hollywood functions. It's currently not possible to catch general lowlevel errors like division by zero or passing not enough arguments to functions etc. ExitOnError(False) is also not able to catch these lowlevel errors. I might extend this in the future to support all errors, though.
Re: How to use RaiseOnError?
Posted: Tue Nov 27, 2012 7:13 pm
by jap
Andreas wrote:I might extend this in the future to support all errors, though.
That would be good.