3 Replies Latest reply on Jun 7, 2012 9:20 AM by Muppet Mark

    Capturing an error and moving on...

    aklyman Level 1

      I've written a script to open some files, do some things, and close. The below sub-script helps to prevents me from having to babysit the opening of thousands of files from various versions of Illustrator. However, I've got some Illustrator CS4 files that show up in the filesystem with PDF icons that choke the script. When attempting to open, the Extendscript window shows "an illustrator error has occurred: -43".  Opening the files any other way with Illustrator CS5 works fine (dragging and dropping, file/open), but double click launches Acrobat.


      I know, I should re-save these files before batch processing, but that requires too much manual checking of the files since any script chokes during the open().


      I'm already writing log files about what's happening, so how can I add a list of files that fail this way, skip them in the queue, and get on with the other 99.9% of the work the script is doing? I don't really need to keep track of what the error was that caused the script (though I'd like to), just need the error trapping script.


      Thanks All.



      #target illustrator

      var problemChild = new File(fileToOpen[a]); //the file to open is fed from another part of the script

      var optRef = new OpenOptions();

      optRef.updateLegacyText = true;

      optRef.convertCropAreaToArboard = true;

      optRef.preserveLegacyArtboard = false;

      optRef.createArtboardWithArtworkBoundingBox = false;


      open(problemChild, DocumentColorSpace.RGB, optRef);

      var errorMessage = "How do I capture the message?";

      if (problemChild.open() = errror ) {errorLog.writeln(fileToOpen[a] + " failed to open because of error " + errorMessage);}