R/myTryCatch.R

Defines functions myTryCatch

# License: https://creativecommons.org/licenses/by-sa/3.0/
# Source: https://stackoverflow.com/a/24569739/342331
myTryCatch <- function(expr) {
    warn <- err <- NULL
    value <- withCallingHandlers(
        tryCatch(expr, error = function(e) {
            err <<- e
            NULL
        }),
        warning = function(w) {
            warn <<- w
            invokeRestart("muffleWarning")
        }
    )
    list(value = value, warning = warn, error = err)
}

Try the marginaleffects package in your browser

Any scripts or data that you put into this service are public.

marginaleffects documentation built on Oct. 20, 2023, 1:07 a.m.