Or set some kind of local_slider_error_call() before going to C that the R error callbacks can look to for the error call
We started using snapshot tests a lot more in #186, so any improvements will be easily visible. Here are a few cases where the error call either is set to NULL and doesn't show or we throw a base R error
library(slider)
slide_int(1, ~1.5)
#> Error:
#> ! Can't convert from <double> to <integer> due to loss of precision.
#> • Locations: 1
#> Backtrace:
#> ▆
#> 1. └─slider::slide_int(1, ~1.5)
#> 2. └─slider:::slide_vec_direct(...) at slider/R/slide.R:295:2
#> 3. └─slider:::slide_impl(...) at slider/R/slide.R:250:2
#> 4. └─slider:::slide_common(...) at slider/R/slide.R:430:2
#> 5. └─slider (local) `<fn>`() at slider/R/slide-common.R:2:2
#> 6. └─vctrs:::vec_cast.integer.double(...)
#> 7. └─vctrs::maybe_lossy_cast(...)
#> 8. ├─base::withRestarts(...)
#> 9. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 10. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 11. └─vctrs:::stop_lossy_cast(...)
#> 12. └─vctrs::stop_incompatible_cast(...)
#> 13. └─vctrs::stop_incompatible_type(...)
#> 14. └─vctrs:::stop_incompatible(...)
#> 15. └─vctrs:::stop_vctrs(...)
#> 16. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))
slide(1, identity, .before = -1)
#> Error: When `.before` (-1) is negative, it's absolute value (1) cannot be greater than `.after` (0).
slide(1, identity, .before = -1, .after = -1)
#> Error: `.before` (-1) and `.after` (-1) cannot both be negative.
slide(1, identity, .before = "x")
#> Error:
#> ! Can't convert <character> to <integer>.
#> Backtrace:
#> ▆
#> 1. ├─slider::slide(1, identity, .before = "x")
#> 2. │ └─slider:::slide_impl(...) at slider/R/slide.R:201:2
#> 3. │ └─slider:::slide_common(...) at slider/R/slide.R:430:2
#> 4. └─vctrs (local) `<fn>`() at slider/R/slide-common.R:2:2
#> 5. └─vctrs::vec_default_cast(...)
#> 6. ├─base::withRestarts(...)
#> 7. │ └─base (local) withOneRestart(expr, restarts[[1L]])
#> 8. │ └─base (local) doWithOneRestart(return(expr), restart)
#> 9. └─vctrs::stop_incompatible_cast(...)
#> 10. └─vctrs::stop_incompatible_type(...)
#> 11. └─vctrs:::stop_incompatible(...)
#> 12. └─vctrs:::stop_vctrs(...)
#> 13. └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call))
Or set some kind of
local_slider_error_call()
before going to C that the R error callbacks can look to for the error callWe started using snapshot tests a lot more in #186, so any improvements will be easily visible. Here are a few cases where the error call either is set to
NULL
and doesn't show or we throw a base R errorCreated on 2022-11-15 with reprex v2.0.2.9000