[REBOL] Error trapping
From: carl:cybercraft at: 24-Dec-2003 22:51
To capture an error object you can use something like this...
>> error? err: try [1 / 0]
== true
>> probe disarm err
make object! [
code: 400
type: 'math
id: 'zero-divide
arg1: none
arg2: none
arg3: none
near: [1 / 0]
where: none
]
but if the TRY block returns nothing it doesn't work...
>> error? err: try []
** Script Error: err needs a value
** Near: error? err: try []
To get around this you can ensure your TRY blocks always return NONE
or FALSE when they otherwise wouldn't return a value, but is there a
simplier way?
--
Carl Read