[R] problem with catching error message in open function

Baoqiang Cao bqcaomail at gmail.com
Wed Sep 24 21:56:51 CEST 2008


Hi R-helpers,

I'm extracting data from an public server, since there is a restriction 
such that I have to submit my entries one by one (I have 10^5 entries). 
I partially succeeded with using

tf <- open(url, "r")
if(isOpen(tf, "r")) {readLines(tf)}
close(tf)

Some entries successfully were returned and read by readLine, then all 
the sudden, the program stopped with the following error:

"The error message is
unable to open connection
cannot open: HTTP status was '502 Bad Gateway'
Execution halted"

Is there anyway that I could catch the error from the "open" function? 
I'd like the program not being halted when the bad connection happens. 
Any help please?

Best,
Baoqiang



More information about the R-help mailing list