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
如果要求它不會產生警告?