Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Trapping errors? - Not like the book says? Re:(2)

From: rebol:techscribe at: 3-Aug-2000 10:59

Hi Eric,
>SEND doesn't return a value, so TRY doesn't return one either. As a >result all the set-word error: sees is the unset! value, which produces >the error.
Exactly.
>If you add 'true to the end of the try block, that >ensures you'll have some value to set 'error to.
1. A better way to do it would be to use set/any 'error try [...] as in:
>> either error? set/any 'error try [print "hi"] [
print "error" ] [ print "no error" ] hi no error
>> either error? set/any 'error try [print 1 / 0] [
print "error" ] [ print "no error" ] error ;- Elan [ : - ) ] author of REBOL: THE OFFICIAL GUIDE REBOL Press: The Official Source for REBOL Books http://www.REBOLpress.com visit me at http://www.TechScribe.com