首页 > 解决方案 > How to pause R script when error

问题描述

I would like to use sys.sleep function when the request of an API I am using gives me an error back. Like this one:

Error in open.connection(con, "rb") : HTTP error 429.

Should I use trycatch?

data<- fromJSON("https://api.com")

Thanks !

标签: rtry-catch

解决方案


您可以使用尝试捕获

tryCatch(myfunc(), error=function(e) Sys.sleep(1))

推荐阅读