Skip to content

Commit 4a3dd71

Browse files
olivroyteunbrand
andauthored
Review error messages (#5557)
* Add full stops to error messages. * Remove self-ref * Replace `expect_snapshot_warning` and `expect_snapshot_error()` with `expect_snapshot()`. * Review and accept snapshots * error msg * style * typo * Revert "Replace `expect_snapshot_warning` and `expect_snapshot_error()` with `expect_snapshot()`." This reverts commit 3b7dcc7. * change * Update snapshots * Adjust failing tests * Apply suggestions from code review Co-authored-by: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> * Apply suggestions from teunbrand --------- Co-authored-by: Teun van den Brand <49372158+teunbrand@users.noreply.github.com>
1 parent c00f875 commit 4a3dd71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+353
-345
lines changed

R/aes.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ alternative_aes_extract_usage <- function(x) {
425425
} else if (is_call(x, "$")) {
426426
as.character(x[[3]])
427427
} else {
428-
cli::cli_abort("Don't know how to get alternative usage for {.var {x}}")
428+
cli::cli_abort("Don't know how to get alternative usage for {.var {x}}.")
429429
}
430430
}
431431

R/annotation-custom.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ GeomCustomAnn <- ggproto("GeomCustomAnn", Geom,
7171
draw_panel = function(data, panel_params, coord, grob, xmin, xmax,
7272
ymin, ymax) {
7373
if (!inherits(coord, "CoordCartesian")) {
74-
cli::cli_abort("{.fn annotation_custom} only works with {.fn coord_cartesian}")
74+
cli::cli_abort("{.fn annotation_custom} only works with {.fn coord_cartesian}.")
7575
}
7676
corners <- data_frame0(
7777
x = c(xmin, xmax),

R/annotation-map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ annotation_map <- function(map, ...) {
6363
if (!is.null(map$long)) map$x <- map$long
6464
if (!is.null(map$region)) map$id <- map$region
6565
if (!all(c("x", "y", "id") %in% names(map))) {
66-
cli::cli_abort("{.arg map} must have the columns {.col x}, {.col y}, and {.col id}")
66+
cli::cli_abort("{.arg map} must have the columns {.col x}, {.col y}, and {.col id}.")
6767
}
6868

6969
layer(

R/annotation-raster.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ GeomRasterAnn <- ggproto("GeomRasterAnn", Geom,
7474
draw_panel = function(data, panel_params, coord, raster, xmin, xmax,
7575
ymin, ymax, interpolate = FALSE) {
7676
if (!inherits(coord, "CoordCartesian")) {
77-
cli::cli_abort("{.fn annotation_raster} only works with {.fn coord_cartesian}")
77+
cli::cli_abort("{.fn annotation_raster} only works with {.fn coord_cartesian}.")
7878
}
7979
corners <- data_frame0(
8080
x = c(xmin, xmax),

R/annotation.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#'
1414
#' @section Unsupported geoms:
1515
#' Due to their special nature, reference line geoms [geom_abline()],
16-
#' [geom_hline()], and [geom_vline()] can't be used with [annotate()].
16+
#' [geom_hline()], and [geom_vline()] can't be used with `annotate()`.
1717
#' You can use these geoms directly for annotations.
1818
#' @param geom name of geom to use for annotation
1919
#' @param x,y,xmin,ymin,xmax,ymax,xend,yend positioning aesthetics -

R/autolayer.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ autolayer <- function(object, ...) {
1515

1616
#' @export
1717
autolayer.default <- function(object, ...) {
18-
cli::cli_abort("No autolayer method available for {.cls {class(object)[1]}} objects")
18+
cli::cli_abort("No autolayer method available for {.cls {class(object)[1]}} objects.")
1919
}

R/autoplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ autoplot <- function(object, ...) {
1717
autoplot.default <- function(object, ...) {
1818
cli::cli_abort(c(
1919
"Objects of class {.cls {class(object)[[1]]}} are not supported by autoplot.",
20-
"i" = "have you loaded the required package?"
20+
"i" = "Have you loaded the required package?"
2121
))
2222
}
2323

R/axis-secondary.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ set_sec_axis <- function(sec.axis, scale) {
123123
if (!is.waive(sec.axis)) {
124124
if (is.formula(sec.axis)) sec.axis <- sec_axis(sec.axis)
125125
if (!is.sec_axis(sec.axis)) {
126-
cli::cli_abort("Secondary axes must be specified using {.fn sec_axis}")
126+
cli::cli_abort("Secondary axes must be specified using {.fn sec_axis}.")
127127
}
128128
scale$secondary.axis <- sec.axis
129129
}
@@ -165,7 +165,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
165165
return()
166166
}
167167
if (!is.function(self$trans)) {
168-
cli::cli_abort("Transformation for secondary axes must be a function")
168+
cli::cli_abort("Transformation for secondary axes must be a function.")
169169
}
170170
if (is.derived(self$name) && !is.waive(scale$name)) self$name <- scale$name
171171
if (is.derived(self$breaks)) self$breaks <- scale$breaks
@@ -194,7 +194,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
194194

195195
# Test for monotonicity
196196
if (!is_unique(sign(diff(full_range))))
197-
cli::cli_abort("Transformation for secondary axes must be monotonic")
197+
cli::cli_abort("Transformation for secondary axes must be monotonic.")
198198
},
199199

200200
break_info = function(self, range, scale) {

R/bin.R

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,11 @@ bin_breaks <- function(breaks, closed = c("right", "left")) {
5151
bin_breaks_width <- function(x_range, width = NULL, center = NULL,
5252
boundary = NULL, closed = c("right", "left")) {
5353
if (length(x_range) != 2) {
54-
cli::cli_abort("{.arg x_range} must have two elements")
54+
cli::cli_abort("{.arg x_range} must have two elements.")
5555
}
5656

57-
check_number_decimal(width)
58-
if (width <= 0) {
59-
cli::cli_abort("{.arg binwidth} must be positive")
60-
}
57+
# binwidth seems to be the argument name supplied to width. (stat-bin and stat-bindot)
58+
check_number_decimal(width, min = 0, allow_infinite = FALSE, arg = "binwidth")
6159

6260
if (!is.null(boundary) && !is.null(center)) {
6361
cli::cli_abort("Only one of {.arg boundary} and {.arg center} may be specified.")
@@ -105,7 +103,7 @@ bin_breaks_width <- function(x_range, width = NULL, center = NULL,
105103
bin_breaks_bins <- function(x_range, bins = 30, center = NULL,
106104
boundary = NULL, closed = c("right", "left")) {
107105
if (length(x_range) != 2) {
108-
cli::cli_abort("{.arg x_range} must have two elements")
106+
cli::cli_abort("{.arg x_range} must have two elements.")
109107
}
110108

111109
check_number_whole(bins, min = 1)

R/compat-plyr.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ unrowname <- function(x) {
1919
} else if (is.matrix(x)) {
2020
dimnames(x)[1] <- list(NULL)
2121
} else {
22-
cli::cli_abort("Can only remove rownames from {.cls data.frame} and {.cls matrix} objects")
22+
cli::cli_abort("Can only remove rownames from {.cls data.frame} and {.cls matrix} objects.")
2323
}
2424
x
2525
}
@@ -239,7 +239,7 @@ as.quoted <- function(x, env = parent.frame()) {
239239
} else if (is.call(x)) {
240240
as.list(x)[-1]
241241
} else {
242-
cli::cli_abort("Must be a character vector, call, or formula")
242+
cli::cli_abort("Must be a character vector, call, or formula.")
243243
}
244244
attributes(x) <- list(env = env, class = 'quoted')
245245
x

0 commit comments

Comments
 (0)