Skip to main content
Kukurykus
Legend
December 9, 2018
Answered

try...catch statement usually not working in Ps CC 2019!

  • December 9, 2018
  • 1 reply
  • 2854 views

Can someone explain what is going on? I ran following script in CS6 EXTENDED and found there is no problem about. Probably that doesn't occur in any later releases prior to newest CC 2019, however that I'm not sure, but in latest CC 2018 I think that worked still smoothly.

How to fix the code it worked as should? After you ran it, it's creating 10 new documents, over-saving each for web on the desktop. When randomally within this short time I stop script by pressing ESC key there happens different things, like:

- sometimes correctly intended alert pops up!

- mostly I'm hearing beep, while script is continued!

- quite often I'm getting error: 'Command could not be completed', then after pressing enter script is continued!

$.level = 0; try{

     for(i = 0; i < 10; i++) {

          opn = documents.add(), opt = new ExportOptionsSaveForWeb()

          opt.format = SaveDocumentType.JPEG, opt.optimized = true, opt.quality = 100

          opn.exportDocument(File('~/desktop/name.jpg'), ExportType.SAVEFORWEB, opt)

     }

}catch(err){alert('Operation got cancelled!')}

I reverted to 2018 twice because of some 'features' that were over my patience, now this scripting bug crosses my limit completely. If anyone knows at least some workaround please share...

I tried it in CC2018 I just installed - it's completely same, but I don't remember I ever had it with any script, why it happens?

This topic has been closed for replies.
Correct answer r-bin

Try this. Although all this is strange.

1 reply

Jarda Bereza
Inspiring
December 9, 2018

If you want to cancel script I would try "app.doProgress()" this is the proper way how to do it. For new PS versions.

Kukurykus
KukurykusAuthor
Legend
December 9, 2018

Can you show how to implement it. I tried it but it doesn't change anything, I'm having still same errors...

r-binCorrect answer
Legend
December 9, 2018

Try this. Although all this is strange.