Page 1 of 1

catching errors - app.onError

Posted: February 8th, 2012, 4:05 am
by Alan Eddie

Code: Select all

app.onError = err;

function err(errString) {  
    alert(errString);
    }

app.onError = err;

Hi there can anybody give me an example of how to use the code above to test if a statment is giving an error,
let the alert happen and if it does, to exit the current script/function?
I'm a bit hazy on callback functions, so not sure how to integrate it into a script.
Thanks a lot.

Code: Select all

function testError(statment) { // the code being a statment.
    
		statment
	
			function appError(errString) { //define error response.
				alert(errString);
				
				 //error was triggered.
				$.writeln("error triggered.");
			} //close sub
	

	if (app.onError){
		
		app.onError=appError;
		return true;
		}
	
	else{
		return false;		
		
		}
Alan.

Re: catching errors - app.onError

Posted: March 6th, 2012, 2:49 am
by Alan Eddie
This was dealt with on the Adobe forums.

A try and catch statment was a more elegant solution for this problem.
Especially as the error was specific and expected in certain situations.

Re: catching errors - app.onError

Posted: September 25th, 2012, 5:48 am
by Klustre
The Adobe thread can be found here:
http://forums.adobe.com/message/4193615#4193615

(Just for reference)