Debugging
When your expression shows a red error banner, these techniques help you figure out what's going wrong.
Expression Code
// Debugging - Throw Error
// Use to debug values in expressions
throw new Error("Error is: " + value);
// Try-Catch Error Handling
// Wrap risky code to handle errors gracefully
try {
var path = thisComp.layer("SEG-1").content("Path 1").path;
var trimPath = thisComp.layer("SEG-1").content("Trim Paths 1").end / 100;
var targetLayer = thisComp.layer("SEG-1");
var point = path.pointOnPath(trimPath);
targetLayer.toComp(point);
} catch (e) {
// Fallback value if error occurs
[0, 0];
}Two techniques:
**throw new Error()** ā Intentionally trigger an error to see a variable's value. The error banner will show what you passed. Remove it once you've found the issue.
**try/catch** ā Wrap risky code so errors don't break your comp. If something fails, the catch block provides a fallback value instead of a red error.