[REBOL] Re: Help me, Obi Reb Kenobi, you're my only hope!
From: lmecir:mbox:vol:cz at: 28-Aug-2002 9:02
Hi Ed,
Rebforce can easily help you.
Try these:
If Error? set/any 'Fred Try [ Print "Get a grip!" ] [ Print
Whatever!
]
If Error? set/any 'Fred Try [ Write %Temp.txt "Yup!" ] [ Print
Whatever!
]
We might call it "a subtle intricacy of the language". This is a feature,
that deserves a lengthy discussion. I would prefer a different behaviour
instead, but the above solution works... The whole trouble is caused by a
situation similar to this:
a: ()
, while this works:
set/any 'a ()
Cheers
-L
----- Original Message -----
From: "Ed Dana" <[EDanaII--Cox--net]>
To: "REBOL List" <[rebol-list--rebol--com]>
Sent: Wednesday, August 28, 2002 4:51 AM
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 ===========