Nothing
#' Take a Bash
#'
#' Equivalent to [tryCatch()].
#'
#' @param expr Expression to run, passed to [tryCatch()].
#' @param e,w An object of class `Error` or `Warning` as
#' returned by [e()] or [w()].
#'
#' @examples
#' safe_log <- function(x){
#' result <- bash(log(x))
#'
#' if(is.e(result))
#' stop(result$stop())
#'
#' return(result)
#' }
#'
#' if(interactive())
#' safe_log("a")
#'
#' @export
bash <- function(expr, e = NULL, w = NULL){
tryCatch(
expr,
error = callback_e(e),
warning = callback_w(w)
)
}
#' Create Callbacks for bash
#'
#' Creates callback for [bash()].
#'
#' @name callbacks
#'
#' @noRd
#' @keywords internal
callback_e <- function(e = NULL){
return(
function(err){
if(is.null(e))
return(e(err))
if(is.function(e))
return(e(err))
return(e)
}
)
}
#' @rdname callbacks
#' @noRd
#' @keywords internal
callback_w <- function(w = NULL){
return(
function(war){
if(is.null(w))
return(w(war))
if(is.function(w))
return(w(war))
return(w)
}
)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.