Hi, The other suggestions will probably bring you to realise this, but I wanted to make it a little more obvious...
When attempting to catch an error and disarm it for your own error handling scheme you will find that using 'set/any is needed rather than a set-word for maximum strength error handling. For example: Use >> if error set/any fred try [print "done"] [print "Error!"] done >> Rather than >> if error fred: try [print "done"] [print "Error!"] All that try does is catches any error that may be encountered and returns it in as an Error! datatype. 'try doesn't care if a datatype that cannnot be assigned via 'set or a set-word is passed, it will only attempt to 'disarm an error within the argument passed to it. HTH Ammon ----- Original Message ----- From: "Ed Dana" <[EMAIL PROTECTED]> To: "REBOL List" <[EMAIL PROTECTED]> Sent: Tuesday, August 27, 2002 7:51 PM Subject: [REBOL] Help me, Obi Reb Kenobi, you're my only hope! > OK, so what's going on here. > > I'm trying to put a little error handling around my application. If it > fails, I need it to send out an alarm. But, depending on the statement, > I get an error when trying to trap the error. > > For example, this works as expected: > > >> If Error? Fred: Try [ 1 / 0 ] [ Print "Whatever!" ] > Whatever! > > As does this: > > >> If Error? Fred: Try [ 1 / 1 ] [ Print "Whatever!" ] > == none > > This too: > > >> If Error? Fred: Try [ Print ] [ Print "Whatever!" ] > Whatever! > > But this doesn't: > > >> If Error? Fred: Try [ Print "Get a grip!" ] [ Print "Whatever!" ] > Get a grip! > ** Script Error: Fred needs a value > ** Near: If Error? Fred: Try [Print "Get a grip!"] > > This is confusing because why should I get an error on something that > doesn't and shouldn't cause an error. > > > This works, of course: > > >> If Error? Fred: Try [ x: 1 ] [ Print "Whatever!" ] > == none > > And this: > > >> If Error? Fred: Try [ x: 1 / 0 ] [ Print "Whatever!" ] > Whatever! > > And so do these: > > >> If Error? Fred: Try [ Do [ 1 / 0 ] ] [ Print "Whatever!" ] > Whatever! > > >> If Error? Fred: Try [ Do [ 1 / 1 ] ] [ Print "Whatever!" ] > == none > > What's perplexing about the previous two is that it is a "Do" statement > that I am trying to execute and trap. Instead of functioning as above, > it blows up and gives me the "needs a value error". > > And curiously, not only does Print fail, but so does Write. And that is > a function that I need error trapping on, if ever there was one. > > >> If Error? Fred: Try [ Write %Temp.txt "Yup!" ] [ Print "Whatever!" ] > ** Script Error: Fred needs a value > ** Near: If Error? Fred: Try [Write %Temp.txt "Yup!"] > > I've even tried disarming the error, but to no avail: > > >> If Error? Fred: Try [ Write %Temp.txt "Yup!" ] [ Print "Whatever!" ] Disarm Fred > ** Script Error: Fred needs a value > ** Near: If Error? Fred: Try [Write %Temp.txt "Yup!"] > > So what gives? Is this some subtle intricacy of the language, a bug, or my normal state of confusion? > > -- > Sincerely, | Mud can make you prisoner, and the plains can bake > Ed Dana | you dry. Snow can burn your eyes, but only people > Software Developer | make you cry. > 1Ghz Athlon Amiga | -- Lee Marvin, Paint Your Wagon. > =========== http://OurWorld.CompuServe.com/Homepages/EDanaII =========== > > > > -- > To unsubscribe from this list, please send an email to > [EMAIL PROTECTED] with "unsubscribe" in the > subject, without the quotes. > > -- To unsubscribe from this list, please send an email to [EMAIL PROTECTED] with "unsubscribe" in the subject, without the quotes.