Skip to content

Commit

Permalink
dev-facing errors should show the lower-level call
Browse files Browse the repository at this point in the history
  • Loading branch information
hfrick committed Jan 29, 2025
1 parent d45e207 commit 9468d58
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions R/grids.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ make_regular_grid <- function(...,
parameters <- dplyr::filter(parameters, !!filter_quo)
}

new_param_grid(parameters, call = call)
new_param_grid(parameters)
}

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -252,16 +252,15 @@ make_random_grid <- function(...,
parameters <- dplyr::filter(parameters, !!filter_quo)
}

new_param_grid(parameters, call = call)
new_param_grid(parameters)
}

# ------------------------------------------------------------------------------

new_param_grid <- function(x = new_data_frame(), call = caller_env()) {
new_param_grid <- function(x = new_data_frame()) {
if (!is.data.frame(x)) {
cli::cli_abort(
"{.arg x} must be a data frame to construct a new grid from.",
call = call
"{.arg x} must be a data frame to construct a new grid from."
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/space_filling.R
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ make_sfd <- function(...,
)
}

new_param_grid(grid, call = call)
new_param_grid(grid)
}

base_recycle <- function(x, size) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/grids.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@
Code
new_param_grid(as.matrix(x))
Condition
Error:
Error in `new_param_grid()`:
! `x` must be a data frame to construct a new grid from.

0 comments on commit 9468d58

Please sign in to comment.