``` r f <- function() { on.exit(stop("!")) } f() #> Error in f(): ! f2 <- function() { withr::defer(stop("!")) } f2() ``` <sup>Created on 2020-09-01 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0.9001)</sup>