[REBOL] Re: Newbie getting head around TRY/DISARM
From: ingo:2b1 at: 14-Nov-2000 23:29
Hi Mat,
because I was pressed for time, this was the first time I
didn't run my examples through Rebol, and ... well, you see :-(
I made one error, really ... I forgot the ' before error,
but Rebol itself made another, because it doesn't catch the
error ...
if error? set/any 'error try [ 0/0 ] [ ; notice 'error
error: disarm error
print [ "Now you can savely work with: " mold error]
]
the 'error is needed, because otherwise error will be evaluated,
actually, this doesn't work either ...
if error? set/any 'error try [ 0 / 0 ] [ ; notice spaces between 0 / 0
error: disarm error
print [ "Now you can savely work with: " mold error]
]
Now _that_ will work.
(Console session)
>> if error? set/any 'error try [ 0 / 0 ] [
[ error: disarm error
[ print [ "Now you can savely work with: " mold error]
[ ]
Now you can savely work with:
make object! [
code: 400
type: 'math
id: 'zero-divide
arg1: none
arg2: none
arg3: none
near: [0 / 0]
where: none
]
The version 0/0 creates a syntax error, because the parser thinks,
that numbers, seperated by "/" must be a date, and 0/0 is by no means
a valid date. These errors seem not to be handled by 'try ... hmmmm
I hope that clarifies it a bit
Ingo
Once upon a time Mat Bettinson spoketh thus:
> Heya Ingo,
>
> IH> if error? set/any error try [ 0/0 ] [
> IH> error: disarm error
> IH> print [ "Now you can savely work with: " mold error]
> IH> ]
>
> This doesn't actually work though? Using true to force error to return
> works though. (so I'm happy!) This just blows out with the actual error and fails to
> trap it at all.
>
> --
> Mat Bettinson - EuroGamer's Gaming Evangelist with a Goatee
> http://www.eurogamer.net | http://www.eurogamer-network.com
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
>
--
do http://www.2b1.de/
_ . _
ingo@)|_ /| _| _ <We ARE all ONE www._|_o _ _ ._ _
www./_|_) |o(_|(/_ We ARE all FREE> ingo@| |(_|o(_)| (_|
._| ._|