Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Error -128 can't be used in El Capitan

For years, I was using this simple Applescript in my Automator applications to silently end workflow if the folder is empty:


on run {input, parameters}


if input is {} then error -128 -- cancel on empty input list


return input

end run

After updating my mac to El Capitan, instead of silently ending the process if folder is empty and proceeding to other task, the process throws out a message "error -128" and stops.


The same automator workflow that includes this script still works ok on my other mac which is on Yosemite. So I guess they changed the way this error is dealt with in El Capitan.


Does anyone knows if there is a workaround or another way how to silently stop an applescript without throwing an error message?


Thank you.

Automator-OTHER, OS X El Capitan (10.11.1)

Posted on Nov 5, 2015 2:20 AM

Reply
5 replies

Nov 5, 2015 4:07 AM in response to Tomas Griger

The following code will force and handle an error -128 condition on El Capitan 10.11.1.


set x to 5


try

if not x is equal to 10 then error -128


on error errmsgnumbererrnbr

error_handler(errnbr, errmsg)

end try


return


on error_handler(nbr, msg)


return display alert "[ " & nbr & " ] " & msg as critical giving up after 10


end error_handler

Nov 6, 2015 11:23 PM in response to Tomas Griger

I could not get VikingOSX post to help me out so I looked up the manual and as far as I could make out setting error -128 is no longer enough, it also needs to be found in a try statement or it will still fail. So all I did was wrap the middle bit of the old script in a try statement and it seems OK now. Hope this works for you.


on run {input, parameters}

try

if input is {} then error -128 -- cancel on empty input list

end try

return input

end run

Error -128 can't be used in El Capitan

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.