How to use RaiseOnError?

Discuss any general programming issues here
Post Reply
User avatar
jap
Posts: 61
Joined: Sun Feb 14, 2010 12:24 pm
Contact:

How to use RaiseOnError?

Post 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?
PEB
Posts: 588
Joined: Sun Feb 21, 2010 1:28 am

Re: How to use RaiseOnError?

Post by PEB »

Place RaiseOnError() AFTER your p_MyError().
User avatar
jap
Posts: 61
Joined: Sun Feb 14, 2010 12:24 pm
Contact:

Re: How to use RaiseOnError?

Post by jap »

Didn't help :( I still get the build in Hollywood error message.
User avatar
jap
Posts: 61
Joined: Sun Feb 14, 2010 12:24 pm
Contact:

Re: How to use RaiseOnError?

Post 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.
PEB
Posts: 588
Joined: Sun Feb 21, 2010 1:28 am

Re: How to use RaiseOnError?

Post 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.
User avatar
jap
Posts: 61
Joined: Sun Feb 14, 2010 12:24 pm
Contact:

Re: How to use RaiseOnError?

Post 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.
User avatar
airsoftsoftwair
Posts: 5887
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: How to use RaiseOnError?

Post 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.
User avatar
jap
Posts: 61
Joined: Sun Feb 14, 2010 12:24 pm
Contact:

Re: How to use RaiseOnError?

Post by jap »

Andreas wrote:I might extend this in the future to support all errors, though.
That would be good.
Post Reply