pablobarbera / streamR

Dev version of streamR package: Access to Twitter Streaming API via R
http://cran.r-project.org/web/packages/streamR/
107 stars 47 forks source link

tryCatch not firing #2

Open Btibert3 opened 10 years ago

Btibert3 commented 10 years ago

Admittedly I am not 100% sure if this could be handled better on my end, but I am attempting to handle errors with tryCatch.

The code below does not successfully catch the error.

  tweets = tryCatch(readTweets(FILE), 
                    error = function(e) e)
  if (inherits(tweets, "error")) {
    cat("file not could be parsed\n")
    next
  }

I have this code in a loop, where FILE is represented by the this file.

Here is the error that I get:

> tweets = tryCatch(readTweets(FILE), 
+                   error = function(e) e)
0 tweets have been parsed. 
Warning message:
In readLines(tweets, encoding = "UTF-8") :
  incomplete final line found on '/home/brock/github/uga-twitter-bot/tweets//uga_06-27-2014-17-24.json'
> tweets
list()

As you can see in the FILE's contents, it appears that the service was disrupted temporarily.

I raise this issue because I am wondering if my tryCatch doesn't fire because the error occurs during the readLines call within readTweets.