Skip to content

Commit

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

0 comments on commit be8c76c

Please sign in to comment.