Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Stopping errors from stopping the program.

 [1/5] from: louisaturk:eudoramail at: 13-Mar-2002 1:27


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 ... }]] Louis

 [2/5] 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
<<quoted lines omitted: 6>>
> 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

 [3/5] from: micael:gullmes:telenordia:se at: 13-Mar-2002 14:00


Hi! the until command will : "Evaluates a block until it is TRUE." the "prin {ftp failed: trying again ... }" returns true, so the until will stop evaluating your code. I believe the following (non tested) code will work. until [ if error? try [write web-address read page-url] [ prin {ftp failed: trying again ... } false ] ] Brgd /Micael -----Ursprungligt meddelande----- Fran: Dr. Louis A. Turk [mailto:[louisaturk--eudoramail--com]] Skickat: den 13 mars 2002 08:27 Till: [rebol-list--rebol--com] Amne: [REBOL] Stopping errors from stopping the program. 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 ... }]] Louis

 [4/5] from: louisaturk:eudoramail at: 16-Mar-2002 10:44


Carl, Sorry to take so long to respond. I had to stop and take care of some other pressing responsibilities. Anyway, many thanks. You solved my problem and also showed me how to test without having to access the internet. As is usually the case with rebol, the solution turned to be so simple. I was pleased to see that I almost had it right; at least I knew to use try. Slowly but surely, I'm learning and becoming more productive. Thanks again! Louis At 11:19 PM 3/13/2002 +1200, you wrote:

 [5/5] from: carl:cybercraft at: 17-Mar-2002 10:08


On 17-Mar-02, Dr. Louis A. Turk wrote:
> Carl, > Sorry to take so long to respond. I had to stop and take care of
<<quoted lines omitted: 4>>
> right; at least I knew to use try. Slowly but surely, I'm learning > and becoming more productive.
Glad to be of help Louis. As to generating errors for testing, there's specific support for it in REBOL, (see the Errors section of the Core Guide), but, umm, I've never got round to learning it, hence the divide-by-zero in my example. (: I guess I probably should though... -- Carl Read

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted