Re: Where do the errors go?
Re: Where do the errors go?
- Subject: Re: Where do the errors go?
- From: Gil Dawson <email@hidden>
- Date: Thu, 10 May 2018 12:35:58 -0700
Hi--
Thanks for your suggestions.
I've convinced myself that, for an application with three handlers -- run, idle
and quit -- execution errors will be treated differently in each handler.
If an execution error happens in the run handler, the application will put up
an error alert, then the run handler will end. However the idle handler will
begin execution immediately and repeat indefinitely. If asked to Quit, the app
will execute the quit handler then Quit.
If an execution error happens in the idle handler, the application will put up
an error alert, then the idle handler will end. However, the idle handler will
execute again after, instead of twenty seconds' delay, thirty seconds' delay
(the default return parameter). The idle handler will then continue cycling
indefinitely, putting up a new alert each time (unless whatever is causing the
execution error is fixed; see below.) If asked to Quit, the app will execute
the quit handler then Quit.
If an execution error happens in the quit handler, nothing unusual will happen
until the application is asked to Quit. When the application is asked to Quit,
however, it will not put up an alert box, nor will it Quit. The application
will simply ignore the request and continue executing its idle handler
indefinitely. Only Force Quit will Quit the application. (That, and fixing
what is causing the execution errors. See below.)
I drew these conclusions from studying executions and the log file of the
script below using Script Editor 2.8.1 with Mac OS 10.11.6. This script causes
execution errors by using the line...
alias [text path to a file]
...which will error if the file does not exist. By slightly renaming the files
tested-for in this script, one can externally control when, and in which
handler, the execution error will occur. Also, one can "fix" what is causing
an error.
I was disappointed to learn from this demonstration that the quit handler will
not inform us of an error via an alert, but now I am pretty sure that it will
not.
Can anyone corroborate my conclusion, perhaps on other OS versions?
--Gil
--For this demonstration, place on the desktop
-- a folder named "Test App Errors"
-- containing four empty files named
-- TestLog.txt
-- TestRun.txt
-- TestIdle.txt
-- TestQuit.txt
-- In Script Editor, Save As...
-- this-here script
-- somewhere handy
-- as an Application
-- with "Keep open after run handler" checked
-- Launch, let run for a minute, then Quit.
-- Then observe the contents of the file "TestLog.txt"
-- Repeat after removing or renaming one or more of the files
on run
logsome(time string of (current date) & " run handler starting." &
return)
alias (((path to desktop folder) as text) & "Test App
Errors:TestRun.txt")
logsome(time string of (current date) & " run handler ending." & return)
return
end run
on idle
logsome(time string of (current date) & " idle handler starting." &
return)
alias (((path to desktop folder) as text) & "Test App
Errors:TestIdle.txt")
logsome(time string of (current date) & " idle handler ending." &
return)
return 20
end idle
on quit
logsome(time string of (current date) & " quit handler starting." &
return)
alias (((path to desktop folder) as text) & "Test App
Errors:TestQuit.txt")
logsome(time string of (current date) & " quit handler ending." &
return)
continue quit
end quit
on logsome(aString)
set TestLog to alias (((path to desktop) as text) & "Test App
Errors:TestLog.txt")
try
close access TestLog
end try
open for access TestLog with write permission
write aString as text to TestLog starting at eof
close access TestLog
end logsome
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden