Error Handler and Stack Trace (Was: Buttons with Display Dialog)
Error Handler and Stack Trace (Was: Buttons with Display Dialog)
- Subject: Error Handler and Stack Trace (Was: Buttons with Display Dialog)
- From: Skeeve <email@hidden>
- Date: Mon, 03 Dec 2007 15:55:21 +0100
Wayne Melrose wrote:
On Dec 3, 2007, at 3:19 PM, Emmanuel wrote:
PS
One of our programmers installs a message display in the "top"
handler, and in the other handlers he propagates the error after
pre-pending the handler's name:
on error errtxt
error "ThisHandlerName: " & errtxt
end
I can second this as a great idea..
dito, but again with modifications. I promote errtxt and errnum
unchanged and copy the stacktrace to a property. The property is then
dumped to the console.
Advantages:
1) Shorter Dialog
2) You can Copy & paste the stacktrace
property stacktrace : ""
on run
try
my first_handler()
on error errtxt number errnum
do shell script "cat > /dev/console <<<" & quoted form of "An
error occured in my application " & return & stacktrace
set stacktrace to ""
display alert "An error occured" message errtxt & return &
"Error Number " & errnum & return & return & "Please consult the console
for a stacktrace" as critical buttons "OK"
end try
end run
on first_handler()
set hndler to "first_handler"
try
-- do something
my second_handler()
on error errtxt number errnum
set stacktrace to stacktrace & hndler & return
error errtxt number errnum
end try
end first_handler
on second_handler()
set hndler to "second_handler"
try
-- do something
my third_handler()
on error errtxt number errnum
set stacktrace to stacktrace & hndler & return
error errtxt number errnum
end try
end second_handler
on third_handler()
set hndler to "third_handler"
try
-- do something
set a to 0
set a to a / a
on error errtxt number errnum
set stacktrace to stacktrace & hndler & return
error errtxt number errnum
end try
end third_handler
_______________________________________________
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