Photoshop: Scripting Errors in Event Handlers aren't caught in try/catch block

  • 1
  • Problem
  • Updated 4 years ago
  • (Edited)
As per the topic title:

try {

var w = new Window('dialog');
var b = w.add('button', undefined, "Error");
b.onClick = function () { throw new Error("BOOM") }
w.show();
} catch (e) {
alert ("" + e.message + "\n" + e.line)
}


The button throws an Error, that is caught - since the script doesn't break.
But no alert pops.
This makes tracking errors quite difficult, unless you wrap with try/catch blocks each handlers content.
Photo of Davide Barranca

Davide Barranca

  • 21 Posts
  • 3 Reply Likes
  • bugged

Posted 5 years ago

  • 1
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 765 Reply Likes
Which version of Photoshop are you using?
Which OS version?
Photo of Davide Barranca

Davide Barranca

  • 21 Posts
  • 3 Reply Likes
Hello Chris,
OSX. It happens on CS5, CS6 and CC.

Thanks,

Davide
Photo of wyeth ridgway

wyeth ridgway

  • 1 Post
  • 0 Reply Likes
Your missing a semi-colon after the alert line?