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

ESTK ignores try/catch during debugging

Participant ,
Nov 03, 2014 Nov 03, 2014

I hope it's not inappropriate to ask about the ESTK here. I use it frequently to debug code, but one irritating facet occasionally trips me up.The ESTK frequently (but not all the time) doesn't respect the try/catch. It will stop on the line in the try and not process the code in the catch. This happens despite my having "Don’t Break On Guarded Exceptions" checked under the Debug menu.

Is this a known issue? Is there a workaround? When I create a test document, of course it works as it should. But in my actual code this isn't the case. Is there some setting I could be adjusting within the code without realizing it?

When it's just a matter of skipping over a line, it doesn't really matter (I can click Run and it will usually move on). But more frequently I need my catch to do something and debugging becomes very difficult without it.

TOPICS
Scripting
1.6K
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

Enthusiast , Dec 22, 2014 Dec 22, 2014

xbytor2 just give me the solution:

When using ESTK debug, the try/catch will not throw error if I put level=0 before and then returning to level 1 after that:

$.level = 0;

try {

     // some code ...

} catch (e) { }

$.level =  1;

Translate
Enthusiast ,
Dec 19, 2014 Dec 19, 2014

I have the same problem using ESTK 4.0.0.1 and CC2014

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
Mentor ,
Dec 19, 2014 Dec 19, 2014

Rather than using them as regular flow control, I leave exceptions to the exceptional circumstances that in any case require programmer attention. The typical check whether a collection has an item for a name is better tested via the isValid property.

Do you happen to have your code wrapped into an app.doScript in order to use undo modes? I remember having trouble with such constructs.

Dirk

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
Enthusiast ,
Dec 19, 2014 Dec 19, 2014

For example, I use this to get annotations on an image document on photoshop.

Running from ESTK it breaks on try/catch

How could I use isValid() to prevent that?

function getAnnotationCount () { 

    var index = 0; 

    while (hideAnnotation (index)) { 

        index++; 

    } 

    return index; 

    // Dummy action, only used to test the existence of an annotation by index... 

    function hideAnnotation (index) {

        var exists = true; 

        var desc = new ActionDescriptor (); 

        var ref = new ActionReference (); 

        ref.putIndex (stringIDToTypeID ('annotation'), index); 

        desc.putReference (stringIDToTypeID ('target'), ref); 

        try { 

            executeAction (stringIDToTypeID ('hide'), desc, DialogModes.NO); 

        } catch (e) { exists = false; }     

        return (exists); 

    }

}

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
Mentor ,
Dec 19, 2014 Dec 19, 2014

Ah, I see what you mean with asking about ESTK in general - there is no class "Annotation" in the object model of my PS / CS6. As I mainly work with InDesign and only in rare cases with Illustrator, I am not used to the tricks required by other target applications e.g. due to lack of scripting support for native features.

Sorry,

Dirk

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
Enthusiast ,
Dec 22, 2014 Dec 22, 2014

xbytor2 just give me the solution:

When using ESTK debug, the try/catch will not throw error if I put level=0 before and then returning to level 1 after that:

$.level = 0;

try {

     // some code ...

} catch (e) { }

$.level =  1;

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
Participant ,
Dec 22, 2014 Dec 22, 2014

I'd love to be able to mark an answer here, but the Adobe forums have been

blocked off to me for days; I just get the dreaded redirect bug which is I

guess a standard feature now. Thanks for looking into this, folks, and if I

can ever log back in I'll happily mark this closed given the tip about

levels.

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
Community Expert ,
Jan 01, 2015 Jan 01, 2015
LATEST

...another way to debug with try/catch is by checking Debug > Don’t Break On Guarded Exceptions in the ESTK

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