Error trapping
[1/3] 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
[2/3] from: ingo:2b1 at: 10-Dec-2003 22:03
Hi Carl,
depends on how you define simpler ...
>> error? set/any 'err try [1 / 0]
== true
>> error? set/any 'err try [print ""]
== false
I just assume that using set/any fits for your definition ;-)
Kind regards,
Ingo
Carl Read wrote:
[3/3] from: carl::cybercraft::co::nz at: 24-Dec-2003 22:51
On 11-Dec-03, Ingo Hohmann wrote:
> Hi Carl,
> depends on how you define simpler ...
<<quoted lines omitted: 3>>
> == false
> I just assume that using set/any fits for your definition ;-)
Thanks Ingor - it does. And it was what I was trying to think of,
having seen it before, but just couldn't remember how it was done...
--
Carl Read
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted