paleolimbot commented on PR #14030:
URL: https://github.com/apache/arrow/pull/14030#issuecomment-1257965065
Thank you for taking this on...I frequently find myself putting a breakpoint
in the `handle_csv_read_error()` to figure this kind of stuff out.
I wonder if classed errors can help us here? We `abort(..., class =
"something")` then `tryCatch(..., something = function(e) { ...handle the
special error with a nicer message but with a reference to the original }`.
rlang has some tooling to make this relatively straightforward:
``` r
rlang::local_interactive()
read_csv <- function() {
rlang::abort("Some message", class = "special_csv_read_error")
}
some_other_fun <- function() {
tryCatch({
read_csv()
}, special_csv_read_error = function(e) {
rlang::abort("Some new message", parent = e)
})
}
some_other_fun()
#> Error in `some_other_fun()`:
#> ! Some new message
#> Caused by error in `read_csv()`:
#> ! Some message
rlang::last_error()
#> Error: Can't show last error because no error was recorded yet
```
<sup>Created on 2022-09-26 by the [reprex
package](https://reprex.tidyverse.org) (v2.0.1)</sup>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]