5 Replies Latest reply on Feb 5, 2010 5:53 AM by penyfai

    try...catch missing links.....

    penyfai

      I've got an indd with missing links and am trying the following to catch the error and report back to user. Unfortunately it is failing...

       

      Can anyone cast any light on why the following is not working please:

       

      try

      {

      app.activeDocument.links.everyItem().unlink();

      }

      catch ( thiserror )

      {

      alert(Error.description)

      };

       

       

      Cheers

        • 1. Re: try...catch missing links.....
          ramkumar.vp Level 3

          Hi,


          Don't use unlink. Try to check this with update() otherwise "linkstatus"


          It will work...


          Regards,

          Ramkumar .P

          • 2. Re: try...catch missing links.....
            penyfai Level 1

            Hi Ramkumar

             

            The thing is that I do want to embed the linked files.

            When I run the embed command in InDesign it will error, therefore I should be able to catch the error description and throw it back to the user.

            The script should then exit, allowing the user to put the problem right.

             

            It did report the error once, but has since stopped producing the message for that doc on subsequent runs of the js.

             

            Am I missing something?

             

            Cheers

            Andrew

            • 3. Re: try...catch missing links.....
              Peter Kahrel Adobe Community Professional & MVP

              Try

               

              try

              {

              app.activeDocument.links.everyItem().unlink();

              }

              catch ( thiserror )

              {

              alert(thiserror.message);

              exit ()

              };

               

               

              Peter

              • 4. Re: try...catch missing links.....
                penyfai Level 1

                Hi Peter

                 

                Tried that too...again the alert doesn't show. I'm using CS3 and where I know the line

                 

                       app.activeDocument.links.everyItem().unlink();

                 

                works if the link is available and using the embed menu item from Links throws an error, I still can't get this error back to the JS.

                 

                Just wondering if it's better to try an 'if' instead....?

                 

                Andrew

                • 5. Re: try...catch missing links.....
                  penyfai Level 1

                  Hi again Ramkumar

                   

                  As it happens, your way to do this was the only one really.

                   

                  Even though unlinking or embedding does throw up errors, they cannot be caught by 'catch'...

                   

                  So we have to

                   

                  try{

                  app.activeDocument.links.everyItem().update();

                  }

                  catch (myupdateerror)

                  {

                  alert(myupdateerror.message);

                  exit()

                  }


                  app.activeDocument.links.everyItem().unlink();

                   

                  Pretty maddening really as you'd expect all commands to act the same. Ah well "C'est la vie" as the English say!

                   

                  Thanks guys

                  Andrew