catching errors - app.onError

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Alan Eddie
Posts: 30
Joined: January 12th, 2012, 1:36 am
Location: Ireland
Contact:

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.
Alan Eddie
_______________________
www.alaneddie.com
3d Animation and VFX
RTE
Dublin
Alan Eddie
Posts: 30
Joined: January 12th, 2012, 1:36 am
Location: Ireland
Contact:

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.
Alan Eddie
_______________________
www.alaneddie.com
3d Animation and VFX
RTE
Dublin
Klustre
Posts: 21
Joined: July 27th, 2011, 2:53 am

The Adobe thread can be found here:
http://forums.adobe.com/message/4193615#4193615

(Just for reference)
Post Reply