streamR icon indicating copy to clipboard operation
streamR copied to clipboard

tryCatch not firing

Open Btibert3 opened this issue 10 years ago • 0 comments

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.

Btibert3 avatar Jun 29 '14 19:06 Btibert3