• 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
Re: Error Message Suppression
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error Message Suppression


  • Subject: Re: Error Message Suppression
  • From: has <email@hidden>
  • Date: Mon, 29 Apr 2002 20:24:14 +0100

Andy Wylie wrote:
>
>bringing an offlist discussion back:
>
>to suppress errors I for some reason adopted...
>
>try
>on error errMessage number errNumber
>end try
>
>...does anyone know of an instance where...
>
>try
>on error
>end try
>
>...will not suffice or was it brain fade.

Both are the same. *However*, it's a good practice to supress only those
errors you want to supress, and throw errors on anything else. For example:

try
--your code
on error
end try

will supress all errors in 'your code', *including* any bugs and user
cancellations (-128). This is generally a Bad Thing, so try to be as
specific as possible. For example:

try
--your code
on error number -1728
end try

Or:

try
--your code
on error eMsg number eNum
if eNum is not in {1, -1728} then error eMsg number eNum
end try


It's also a good idea to comment such code, explaining what behaviour
you're deliberately supressing, and why:

set lst to {"foo", "bar"}
set cnt to 1
try
repeat
display dialog lst's item cnt
set cnt to cnt + 1
end repeat
on error number -1728 -- supress the error that occurs when cnt > lst's
length, and continue with rest of script
end try


HTH

has

--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Scripting Entourage 2001
  • Next by Date: Re: Best lib for large tables?
  • Previous by thread: Re: Error Message Suppression
  • Next by thread: Scripting "Print Center" in X
  • Index(es):
    • Date
    • Thread