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

[REBOL] Help me, Obi Reb Kenobi, you're my only hope!

From: edanaii::cox::net at: 27-Aug-2002 19:51

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 ===========