Skip to content

Commit d7abd63

Browse files
olivroylionel-
andcommitted
Show how to use call = base::call() in abort() (#1704)
* Show how to use call = `base::call()` * Tweak wording and fix missing `message` argument --------- Co-authored-by: Lionel Henry <[email protected]>
1 parent ec443be commit d7abd63

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

R/cnd-abort.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@
246246
#' })
247247
#' )
248248
#'
249+
#' # You can also hard-code the call when it's not easy to
250+
#' # forward it from the caller
251+
#' f <- function() {
252+
#' abort("my message", call = call("my_function"))
253+
#' }
254+
#' g <- function() {
255+
#' f()
256+
#' }
257+
#' # Shows that the error occured in `my_function()`
258+
#' try(g())
259+
#'
249260
#' }
250261
#' @export
251262
abort <- function(message = NULL,

man/abort.Rd

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)