From 08b7443d096d120dda9cc75d54af6a61b0f65362 Mon Sep 17 00:00:00 2001 From: "alex.hill@gmail.com" Date: Wed, 21 Aug 2024 16:58:08 +0100 Subject: [PATCH] condition message --- R/utils.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)))) }