diff --git a/R/cnd-abort.R b/R/cnd-abort.R index da74cb7e6..f9bb80978 100644 --- a/R/cnd-abort.R +++ b/R/cnd-abort.R @@ -246,6 +246,17 @@ #' }) #' ) #' +#' # You can also hard-code the call when it's not easy to +#' # forward it from the caller +#' f <- function() { +#' abort("my message", call = call("my_function")) +#' } +#' g <- function() { +#' f() +#' } +#' # Shows that the error occured in `my_function()` +#' try(g()) +#' #' } #' @export abort <- function(message = NULL, diff --git a/man/abort.Rd b/man/abort.Rd index edcd31366..1fdcbd816 100644 --- a/man/abort.Rd +++ b/man/abort.Rd @@ -338,6 +338,17 @@ try( }) ) +# You can also hard-code the call when it's not easy to +# forward it from the caller + f <- function() { + abort("my message", call = call("my_function")) +} +g <- function() { + f() +} +# Shows that the error occured in `my_function()` +try(g()) + } } \seealso{