[REBOL] Re: Stopping errors from stopping the program.
From: carl:cybercraft at: 13-Mar-2002 23:19
On 13-Mar-02, Dr. Louis A. Turk wrote:
> Hi rebols,
> How do I stop an error from stopping my program? I am sending a file
> to a remote server every 10 minutes to update data. When there is
> too much traffic on the net or the remote server is too slow
> receiving the file, an error occurs which results in my program
> dying. I want it to keep trying until it succeeds no matter how long
> that takes. Here is what I have tried, but it doesn't seem to work
> (that is, errors still stop the program):
> until [not error? try [write web-address read page-url] [prin {ftp
> failed: trying again ... }]]
Hi Louis,
Your problem is there's no 'if in the above so the second block isn't
evaluated, yet it is returned to 'until for checking if it's true or
false. Here's a simplier version which shows what's happening
without the need to access a website...
>> until [not error? try [1 / 0][prin "Error"]]
== [prin "Error"]
This is detecting the error but just shrugging its shoulders about it
and moving on to what's next - which is the block. (Sorry - it's
late:)
I found it simpliest to use 'either to get it working...
>> until [either error? try [1 / 0][print "Error" false][true]]
Error
Error
Error
Error
(escape)
>> until [either error? try [1 / 1][prin "Error" false][true]]
== true
HTH.
--
Carl Read