Page 1 of 1

Checking for template validity

Posted: April 6th, 2006, 8:28 am
by byronnash
I want to build a somee error reporting into a script that uses Render Settings and Output Module Templates. Is there a quick way to check to make sure that a template exists? The only thing I though of was adding a comp and applying a template to see if it fails. Anyone have a better idea?

template checks

Posted: April 6th, 2006, 9:38 am
by redefinery
Hey Byron,

Because those templates are referenced by name, that's the only way I know of to detect for the existence.

I had to do something similar (add a temp comp to the RQ) in my rd: Render Layers script (http://www.redefinery.com/ae/view.php?i ... nderLayers) to retrieve the list of available RS and OM templates.

Jeff

Posted: April 7th, 2006, 8:46 am
by byronnash
I am trying to sort this problem out. I have not used try{} catch{} before so I'm sort of fumbling around. Below is my code snippet. I'm still getting an normal debug error and not the one I have in catch. What am I doing wrong? The "movOM" is assumed to be and invalid template name in this example.

Code: Select all

	var tempQ = app.project.renderQueue.items.add(myComp); //add item to the Render Queue
	try{
		tempQ.outputModules[1].applyTemplate(movOM);
	}
	catch(e){
		alert(e + " Please Load the Output Module Templates")
	}

Error object

Posted: April 7th, 2006, 9:03 am
by redefinery
Hey Byron,

The "e" is the Error object. It looks like you're trying to print it out as a string along with your message. If so, use e.toString() or e.message (e.name would return "Error"). If you're just wanting your error string, then don't prefix the e variable to it.

Otherwise, your try/catch block looks fine.

Jeff

Posted: April 7th, 2006, 11:35 am
by byronnash
I am still getting an error on the line where I add the bad template. It just pops a normal error out and kills the script. Am I misunderstanding what try catch does?

Accessing OM templates

Posted: April 7th, 2006, 7:08 pm
by redefinery
Hmm, I can sometimes see the error you're talking about in the try block and othertimes get the error in the catch block. See if changing the OM reference from outputModules[1] to outputModule(1) to see if it makes a difference.

Also, are you doing this in AE 6.5 or 7? If in 7, are you launching the script from AE or ESTK? If AE, is the Enable JavaScript Debugger option enabled? If in ESTK, is the Debug > Don't Break on Guarded Exceptions option enabled?

In theory, if an error is raised in one of your statements within the try block, the catch block should be called.

Jeff