diff --git a/R/utils.R b/R/utils.R index 338b91d..b3b2911 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,10 +1,13 @@ with_warnings <- function(expr) { my_warnings <- NULL + w_handler <- function(w) { my_warnings <<- c(my_warnings, list(w)) invokeRestart("muffleWarning") } + val <- withCallingHandlers(expr, warning = w_handler) - list(output = val, warnings = lapply(my_warnings, - function(w) jsonlite::unbox(w$message))) + list(output = val, + warnings = lapply(my_warnings, + function(w) jsonlite::unbox(conditionMessage(w)))) }