diff --git a/R/aaa.R b/R/aaa.R index 0ad4cce..c8bb293 100644 --- a/R/aaa.R +++ b/R/aaa.R @@ -1,13 +1,14 @@ #' @importFrom rlang check_installed abort NULL -check_palette <- function(palette, names) { +check_palette <- function(palette, names, call = rlang::caller_env()) { if (!(palette %in% names)) { abort( paste0( "Palette not found. Make sure both package and palette ", - 'name are spelled correct in the format "package::palette"' - ) + 'name are spelled correct in the format "package::palette".' + ), + call = call ) } } diff --git a/R/paletteer_c.R b/R/paletteer_c.R index 63f8751..f86920d 100644 --- a/R/paletteer_c.R +++ b/R/paletteer_c.R @@ -13,7 +13,7 @@ #' @export paletteer_c <- function(palette, n, direction = 1) { if (abs(direction) != 1) { - abort("direction must be 1 or -1") + abort("`direction` must be 1 or -1.") } palette <- try(palette, silent = TRUE) diff --git a/R/paletteer_d.R b/R/paletteer_d.R index c244d95..3a26cb0 100644 --- a/R/paletteer_d.R +++ b/R/paletteer_d.R @@ -18,7 +18,7 @@ paletteer_d <- function(palette, n, direction = 1, type = c("discrete", "continuous")) { if (abs(direction) != 1) { - abort("direction must be 1 or -1") + abort("`direction` must be 1 or -1.") } type <- match.arg(type) diff --git a/R/paletteer_dynamic.R b/R/paletteer_dynamic.R index 9a0c9db..2315041 100644 --- a/R/paletteer_dynamic.R +++ b/R/paletteer_dynamic.R @@ -14,11 +14,11 @@ #' @export paletteer_dynamic <- function(palette, n, direction = 1) { if (abs(direction) != 1) { - abort("direction must be 1 or -1") + abort("`direction` must be 1 or -1.") } if (missing(n)) { - abort("n not found. Please supply the number of colors you want returned.") + abort("`n` not found. Please supply the number of colors you want returned.") } palette <- try(palette, silent = TRUE) diff --git a/tests/testthat/_snaps/paletteer_d.md b/tests/testthat/_snaps/paletteer_d.md index f53fb8b..4d513b5 100644 --- a/tests/testthat/_snaps/paletteer_d.md +++ b/tests/testthat/_snaps/paletteer_d.md @@ -3,6 +3,6 @@ Code paletteer_d("paletteer::notreal") Condition - Error in `check_palette()`: - ! Palette not found. Make sure both package and palette name are spelled correct in the format "package::palette" + Error in `paletteer_d()`: + ! Palette not found. Make sure both package and palette name are spelled correct in the format "package::palette".