Throwing Errors in Functions?
Throwing Errors in Functions?
- Subject: Throwing Errors in Functions?
- From: Alex Hall <email@hidden>
- Date: Tue, 10 Mar 2015 23:56:11 -0400
Hello list, I've seen plenty about catching errors in try/on error blocks, and I've used them many times. I'm calling my own functions, though, and I'd like to use errors instead of a return code or checking the class of the returned item to see if my functions worked. That is:
on doMyFunction(x) if x<10 then throw msg "x cannot be less than 10." number -1 end if return "x="&(x as text) end doMyFunction
try set y to doMyFunction(5) display dialog "It worked, " & (y as text) on error msg number eNumber display dialog "error " & eNumber & ": " & msg end try
Of course, the bit that I'm not sure about is my made-up "throw" statement. Does AS have a native way of doing this, or is it down to return codes/values? Thanks!
--
Have a great day, Alex Hall
|
_______________________________________________
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