Thanks!

Just prior to getting your email, I tried putting (error: none)
right after send... in the block. It works also.

So I hope this saves some other soul some frustration.
In fact I can just put: yes, or no, or none - just so that 
"try" will return some value.

You are correct in pointing out that send returns "no value" at all, 
since even returning none, makes the function work.
 
if error? error: try [send  [EMAIL PROTECTED]  {test} yes ][
   log-event/error system/script/header/file "error" (disarm error)
 ] 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 03, 2000 11:17 AM
To: [EMAIL PROTECTED]
Subject: [REBOL] Re:Trapping errors? - Not like the book says?



Hi Doug,

Why don't you try it this way:

if error? error: try [send  [EMAIL PROTECTED]  {test} true ][
   log-event/error system/script/header/file "error" (disarm error)
 ]

SEND doesn't return a value, so TRY doesn't return one either. As a
result all the set-word error: sees is the unset! value, which produces
the error. If you add 'true to the end of the try block, that
ensures you'll have some value to set 'error to. Here's an illustration
with PRINT, another function that returns no value.

>> type? try [print "hello"]
hello
== unset!
>> error? try [print "hello"]            ; ERROR? doesn't mind unset!
hello
== false
>> error? error: try [print "hello"]     ; but error: can't stand it
hello
** Script Error: error needs a value.
** Where: error? error: try [print "hello"]
>> error? error: try [print "hello" true]   ; give it TRUE to keep it happy
hello
== false

See you,
Eric

Reply via email to