Skip to content

Commit

Permalink
condition message
Browse files Browse the repository at this point in the history
  • Loading branch information
hillalex committed Aug 21, 2024
1 parent 6d2f818 commit 08b7443
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -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))))
}

0 comments on commit 08b7443

Please sign in to comment.