3
检查下面的例子:为什么tryCatch在被要求生产时不会返回警告?
library(testthat)
expect_warning(tryCatch(stop("Error!"), error = function(e) warning(e)))
## Error: tryCatch(stop("Error!"), error = function(e) warning(e)) showed 0 warnings
## In addition: Warning message:
## In doTryCatch(return(expr), name, parentenv, handler) : Error!
为什么testthat说,没有警告?
使用withWarnings
function discussed in here也没有显示警告信号。为什么tryCatch
如果要求它不会产生警告?