Skip to content

Commit

Permalink
Capture interrupts and error
Browse files Browse the repository at this point in the history
Fixes #314
  • Loading branch information
hadley committed Apr 24, 2017
1 parent 29071ac commit 4ab056f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Expand Up @@ -30,6 +30,10 @@ There have also been two changes to eliminate name conflicts between purrr and d
refer to arguments by position with `..1`, `..2`, and so on. This makes it
possible to use the formula shorthand for functions with more than two
arguments (#289).

* `possibly()`, `safely()` and friends no longer capture interrupts: this
means that you can now terminate a mapper using one of these with
Escape or Ctrl + C (#314)

## Map functions

Expand Down
9 changes: 9 additions & 0 deletions R/output.R
Expand Up @@ -82,6 +82,9 @@ possibly <- function(.f, otherwise, quiet = TRUE) {
if (!quiet)
message("Error: ", e$message)
otherwise
},
interrupt = function(e) {
stop("Terminated by user", call. = FALSE)
}
)
}
Expand Down Expand Up @@ -109,6 +112,9 @@ auto_browse <- function(.f) {
frame <- ctxt_frame(7)
browse_in_frame(frame)
}
},
interrupt = function(e) {
stop("Terminated by user", call. = FALSE)
}
)
}
Expand All @@ -135,6 +141,9 @@ capture_error <- function(code, otherwise = NULL, quiet = TRUE) {
message("Error: ", e$message)

list(result = otherwise, error = e)
},
interrupt = function(e) {
stop("Terminated by user", call. = FALSE)
}
)
}
Expand Down

0 comments on commit 4ab056f

Please sign in to comment.