Open hadley opened 4 months ago
Does this help?
wrap <- function(expr) {
withCallingHandlers(
expr,
error = function(cnd) {
abort(cnd_message(cnd), footer = c("i" = "bar"))
}
)
}
wrap(1 + "")
#> Error in `h()`:
#> ! non-numeric argument to binary operator
#> ℹ bar
Yes!
oh weird :/
wrap(cli::cli_abort(c("a", i = "b", x = "c")))
#> Error:
#> ! a ℹ b ✖ c
#> ℹ bar
In some situations you know the probable cause of an error, and there's a specific fix that the user might want to try first. Ideally this would be added as some sort of trailing hint, but we don't have a great technique for that currently.
e.g. https://github.com/tidyverse/dbplyr/pull/1459, https://github.com/r-dbi/odbc/pull/744/files#diff-ef8dcd24d5337937983c4c56ba9146ec1fd06d22851849ff570ffdc7ad051a58R33