From be8c76c495608f69e173002b37d3ab44c6dc52e1 Mon Sep 17 00:00:00 2001 From: "alex.hill@gmail.com" Date: Wed, 21 Aug 2024 16:59:37 +0100 Subject: [PATCH] cleaner code --- R/utils.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/R/utils.R b/R/utils.R index b3b2911..cd24f4b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -2,12 +2,11 @@ with_warnings <- function(expr) { my_warnings <- NULL w_handler <- function(w) { - my_warnings <<- c(my_warnings, list(w)) + my_warnings <<- c(my_warnings, jsonlite::unbox(conditionMessage(w))) invokeRestart("muffleWarning") } val <- withCallingHandlers(expr, warning = w_handler) list(output = val, - warnings = lapply(my_warnings, - function(w) jsonlite::unbox(conditionMessage(w)))) + warnings = my_warnings) }