TryCatch, when getting no data

Hey!

I have a function, which gets OHLC data. Sometimes, data are't available (depending on time) and, if so, there occures an Error and everything stops. In this case, it should ignore the Error and go on. Could there a tryCatch help?

The error looks like this:

I hope someone can help me... :slight_smile:

Yes, use try catch or even just try.

I tried something like this, but the retrying-Error occures again:

fromDatePT = "2021-07-12"


getData = sapply(fromDatePT, function(x) {
  
  tryCatch(
    
    {
      
      dt.Wed <- GetRemoteData(source = "Montel", requestType = "trade", fromDate = fromDatePT, toDate = "", v.ids = c("EEX DEB D2"))
      
    }, error = function(msg){
      return(NA)
    }
  )
  
  
})

is your function a private one you wrote, or from a package ?
If it has options to not retry after 5 seconds, it would make sense to use that option.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.