Try Catch not catching "error : unknown IO error" - I/O warning : failed to load external entity

Viewed 1071

The code underneath is part of a function. The getLatestFileName function gets a correct fileName (locally stored).

The error is caused by the tryCatch expression: result <- try(xbrlDoAll...) Even though I tried to catch it with a try function and a try catch, I even changed options to show.error.messages = FALSE. I keep getting following output which causes R to crash:

[1] "FINAL STEP"

[1] "STEP 1"

error : Unknown IO error

I/O warning : failed to load external entity "http://xbrl.us/us-gaap/1.0/elts/us-gaap-all-2008-03-31.xsd"

Based on what I got printed, I suppose the error is caused by the XBRL package, when it tries to get info from the url above.

Can someone help me out?

  instance <- getLatestFileName(ticker, date, type)
  options(stringsAsFactors = FALSE)
  result <- NA
  #result <- try(xbrlDoAll(instance, cache.dir = "XBRLcache", prefix.out = NULL), silent = TRUE)

  tryCatch({
      print("STEP 1")
      options(show.error.messages = FALSE)
      result <- try(xbrlDoAll(instance, cache.dir = NULL, prefix.out =  NULL), silent = TRUE)
      print("STEP2")
    }, warning <- function(w) {
      result <- NA
      print("WARNING")
    }, error = function(e) {
      result <- NA
      print(result)
      print("Test")
    }, finally <- {
      print("FINAL STEP")
    })

  try(is.na(result))
  print("we did get here")
1 Answers
Related