• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Error Handler and Stack Trace (Was: Buttons with Display Dialog)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Buttons with Display Dialog (From: Kevin Ballon <email@hidden>)
 >Re: Buttons with Display Dialog (From: Peter Baxter <email@hidden>)
 >Re: Buttons with Display Dialog (From: Skeeve <email@hidden>)
 >Re: Buttons with Display Dialog (From: Emmanuel <email@hidden>)
 >Re: Buttons with Display Dialog (From: Skeeve <email@hidden>)
 >Re: Buttons with Display Dialog (From: Emmanuel <email@hidden>)
 >Re: Buttons with Display Dialog (From: Wayne Melrose <email@hidden>)

  • Prev by Date: Re: Buttons with Display Dialog
  • Next by Date: Re: how to refer to environment variable in a Terminal do script?
  • Previous by thread: Re: Buttons with Display Dialog
  • Next by thread: Re: Buttons with Display Dialog
  • Index(es):
    • Date
    • Thread