[REBOL] Re: And another stumper....
From: anton:wilddsl:au at: 30-Aug-2007 13:55
Tim is correct, you have to be more careful
handling errors. Example, this is not enough
to trap the error:
my-error: try [1 / 0] disarm my-error
In the first expression above, the set-word
looks for a value, and gets an error from TRY.
The result returned is the value of the set-word,
which is the error, so it is left to "explode".
You can do this:
disarm my-error: try [...]
but that assumes that there always will be an error.
It will fail when your code does not make an error:
disarm my-error: try [print 100]
So a way that handles all errors and normal return values
if error? set/any 'my-error try [...][
print mold disarm my-error
Yes, it is quite wordy, but it's possible to refactor
into helper functions, as Ladislav has done.