[REBOL] read URL => error, exists? URL => false (SAMPLE CODE ATTACHED)
From: princepawn::lycos::com at: 11-Sep-2000 13:31
>> read ftp://1.1.1.1
connecting to: 1.1.1.1
** User Error: Failed login to 1.1.1.1 as anonymous. Check your login.
** Where: read ftp://1.1.1.1
>> exists? ftp://1.1.1.1
connecting to: 1.1.1.1
== false
>>
is this a valid set of responses? Or, because there was a read error in both cases, should
an error always be thrown?
I have a piece of code which behaves in certain ways based on errors and other ways based
on failures and unfortunately the behavior for a failure is being triggered when the
behavior for error should occur in both cases.
wait-duration: 0:5:00
host-cycle: func [ _until-b [block!] "we wait for this to happen"
_then-b [block!] "when until-b true, we do this"
/local until-b then-b connect-attempts error-count status quitting-time new-until-b ftp-host
] [
print reform [ "here is until-b:" _until-b newline newline "and here is then-b:" _then-b
]
quitting-time: now/time + wait-duration
error-count: 0
until [
forall ftp-hosts [
ftp-host: first ftp-hosts
until-b: replace (copy _until-b) 'ftp-host ftp-host
then-b: replace (copy _then-b) 'ftp-host ftp-host
print reform [ "trying ftp host:" ftp-host newline "doing" until-b ]
either error? status: try until-b [ print reform "error attempting" until-b ][
either not status [
error-count: error-count + 1
print reform [ until-b "unsuccessful" ]
wait 15
] [
print reform [ until-b "successful... executing" then-b ]
do then-b
break
]
]
]
ftp-hosts: head ftp-hosts
any [ (now/time > quitting-time) (error-count > max-connect-retries) status ]
]
]
until-b: compose [ _url: form-url (ftp-username) (ftp-password) ftp-host (ftp-dir)
print reform [ "url is" _url ]
_upfile-url: to-url rejoin [ _url (upfile-name) ]
print reform [ "checking existence of" _upfile-url ]
exists? _upfile-url ]
then-b: compose [ upload-file (ftp-username) (ftp-password) ftp-host (pgp-outfile) (pgp-outfile)
(ftp-dir)
upload-file (ftp-username) (ftp-password) ftp-host (upfile-name) (upfile-name) (ftp-dir)
]
host-cycle until-b then-b ;;; call host-cycle