Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Photoshop CC Update broke Try/Catch on ActionSets

Contributor ,
Jul 06, 2015 Jul 06, 2015

Can anyone else, running the latest version of Photoshop CC, confirm that an error message is being popped up whenever you use a try/catch to attempt to run an action that doesn't exist?  Below is an example of my code:

    try {

        var actionName = fr.getSubFeatureList.getPrimaryAction(feature); //Returns the first likely action name, a string variable such as "primary" which may or may not exist (in the case of the error, it does not)

        app.doAction(actionName,"saving");

    } catch(e) {

        //This is showing the error that should be getting caught and suppressed.

        //The rest of the statement works, but the error message is defeating the purpose of automation...

        //Error message: "The object 'action 'primary' of set 'saving' is not currently available."

        try {

            var actionName = fr.getSubFeatureList.getSecondaryAction(feature); //Returns a secondary action name if the first fails, such as "secondary"

            app.doAction(actionName,"saving");

        } catch(e1) {

            errLog.addError("The " + fr.getSubFeatureList.getPrimaryAction(feature) + " action could not be found.");

            return;

        }

    }

Can anyone else confirm this issue?  It only appears to be happening when dealing with actions and it is happening on a statement that has been used, without issue, for several months up until the latest update.

TOPICS
Actions and scripting
573
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Jul 06, 2015 Jul 06, 2015

Confirmed with this code:

try {

  app.doAction("xxx", "Default Actions");

} catch (e) {

   alert(e); 

}

It behaves like this back to CS5. You need to check that the action exists before calling app.doAction. There are a few cases like this where an error occurs that cannot be handled with a try/catch block. Opening up a corrupt image file will do the same.

Oddly, I do have code from years ago that expects an exception to be thrown. Not sure why, though. Might not have ever been used.

There is a functio

...
Translate
Adobe
Advisor ,
Jul 06, 2015 Jul 06, 2015

Confirmed with this code:

try {

  app.doAction("xxx", "Default Actions");

} catch (e) {

   alert(e); 

}

It behaves like this back to CS5. You need to check that the action exists before calling app.doAction. There are a few cases like this where an error occurs that cannot be handled with a try/catch block. Opening up a corrupt image file will do the same.

Oddly, I do have code from years ago that expects an exception to be thrown. Not sure why, though. Might not have ever been used.

There is a function  (psx.getActionSets()) in ContactSheetII.jsx that returns an array of action set objects. You can use to verify the action you want to execute actually does exist.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 06, 2015 Jul 06, 2015
LATEST

Strange, this has always worked for me up until the latest update.  Anyway, it did always feel kind of strange having to use a try/catch to check if something existed, and was only used due to being unaware of any other method, at the time.  Thank you for the reply!  It will look much more polished without the try/catch statement.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines