catech(e) not working correctly for user abort

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

ddbell

catech(e) not working correctly for user abort

Post by ddbell »

I built in a try/catch for my script to undo what the script does if it gets aborted. There are times when this doesn't work correctly. Some times I get the following error.

error 8007: User cancelled the operation
Line 6151

The strange this is that line 6151 is the first line inside the function called "delete_effect" which is called by the catch(e). This function only runs from the catch(e) and not from anywhere else. Therefore the catch(e) must be getting triggered. The only thing that I can think of is that maybe the esc key is getting double processed. The first time, it triggers the catch(e) and the second time it aborts the code which runs from the catch(e).

I can simulate this easily when running the script from ESTK. Whenever I just hold the esc key down without letting up, this always occurs. However, when running from Photoshop, its hit and miss. When running from Photoshop, It seems that the problem almost always occurs if the script is cancelled during a time consuming operation. If its not during one of the longer operations then it just randomly happens.

If I hard code an error anywhere in the script then the catch(e) works correctly and the show_error(e) function runs just fine. This issue is only with a user pressed esc key.

Anyone seen this happen before? I get this on CS4 and CS5 windows (haven't tested Mac or versions prior to CS4).

Code: Select allcatch(e){

delete_effect ();

if (e.number != 8007) {show_error(e);}
else {alert ('Stopped by user');}
 }




Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

catech(e) not working correctly for user abort

Post by Mike Hale »

Like you say it seems to depend on what the script is doing and how the user presses the esc key but I have not been able to come up with a way to trap the esc key that works 100% of the time.
ddbell

catech(e) not working correctly for user abort

Post by ddbell »

OK, Thanks.

Who knows, maybe Adobe doesn't want to allow the esc key be trapped??? I could see where this could cause a user to be stuck in a script which is looping with no way out. With my script there is no dialog open so I need for the esc key to be used because it's the only way out of the script. I just don't want the esc command to be double processed is all.

I guess it not a big deal anyway so I'll just not worry about it and move on to something else.
Mike Hale

catech(e) not working correctly for user abort

Post by Mike Hale »

Sometimes pressing the esc key will not stop a script if it it running a fast loop.

The reason I wanted to trap the esc key is because sometimes I want to be able to run 'cleanup' code to protect script assets that the end user should not be able to access. That is only needed for scripts that are being offered for sale. Sometimes just encoding the script as binary is not enough to protect the script's workflow.