6 Replies Latest reply on Nov 13, 2012 9:36 AM by Michael L Hale

    Debugger pops up with no error

    byronnash Level 1

      A client of mine is testing a script on OSX Photoshop CS6. Recent versions of the script have been working but now it fails in an unusual way. An dialog come up as part of the script and at a certain point, Extendscript pops up like there is an error. But no code shows in the window and no message about what line it failed on. Normally, when a script fails the debugger pops up showing what line it had an error right? At least that is what it is doing on my PC here. This is the first time we have had this error. Up until now, he always has a line to send me that the script failed on. 

        • 1. Re: Debugger pops up with no error
          Michael L Hale Level 5

          It's hard to say without seeing the script but one thing I would check for is a $.write() or $.writeln() statement. Either of those would bring up ESTK( with the results of that line in the console ).

           

          Next I would review all the code in any of the dialog controls callbacks. I have found that errors in a event handler don't always display an error message. Sometimes they don't even stop the scirpt. It just skips the code in the callback after the line that causes the error.

          • 2. Re: Debugger pops up with no error
            byronnash Level 1

            It was the $.writeln(). I just started using that for debugging instead of alerts. Is there a way to get debugging feedback like that and leave it enabled so the script is funcitonal for the end user but still debug friendly on the back end?

            • 3. Re: Debugger pops up with no error
              Michael L Hale Level 5

              There is no way I know of to tell the script to ingore $.writeln functions( other than commenting them out before saving the file ).

               

              One thing you could do is write to a log file instead of the ESTK console. That way you have the best of both worlds. If there is no errors the end user isn't bothered and if there is you can ask for the log to be sent to you. Of course you would have to open/reopen the log file when debugging as the messages would no longer be sent to ESTK.

               

              Xbytor has some code in xtools for creating error logs.

              1 person found this helpful
              • 4. Re: Debugger pops up with no error
                byronnash Level 1

                I like the idea of switching to a log file. I have used one in the past occaisionally. How does the file get handled if the script crashes? Does it get written at all then or only after the app closes?

                • 5. Re: Debugger pops up with no error
                  Muppet Mark Level 5

                  I have wrapped my $.write() & $.writeln() in an if statement to a variable at the top… But soon got feed up with that…

                   

                  Much easier is use the ESTK find and replace… find $.write replace //$.write

                  • 6. Re: Debugger pops up with no error
                    Michael L Hale Level 5

                    What I would do is put any code that might crash the script in a try/catch. In the catch block write the error to the log file then stop the script. In other words use try/catch so the script doesn't crash. The worst that could happen is it catches an error it can't handle and stops the script. That will give the script a chance to log the errror for later debugging and avoid the in your face defalut error message.