[REBOL] Re: Catching net errors
From: lmecir:mbox:vol:cz at: 14-Jan-2001 22:46
A comfortable solution can be:
>> gd-try [print 1 / 0] [print mold disarm last-error]
make object! [
code: 400
type: 'math
id: 'zero-divide
arg1: none
arg2: none
arg3: none
near: [print 1 / 0]
where: 'gd-try
]
>> gd-try [print 1 / 1] [print mold disarm last-error]
1
The source of the function:
gd-try: function [
{A Goal Directed version of the TRY native.}
[throw]
block [block!]
error-handler [block!]
] [result] [
either error? set/any 'result try block [
error? last-error: :result
do error-handler
] [
get/any 'result
]
]