Checking for template validity

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

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?
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

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
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

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")
	}
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

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
byronnash
Posts: 321
Joined: July 7th, 2004, 2:30 pm
Location: Charlotte, NC
Contact:

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?
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

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
Post Reply