Skip to content

Commit

Permalink
Fix error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Feb 22, 2024
1 parent ec911d8 commit 62555b0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/geom-ribbon.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ GeomRibbon <- ggproto("GeomRibbon", Geom,
# these to vary
non_constant <- setdiff(non_constant, c("fill", "alpha"))
}
if (length(non_constant) > 1) {
if (length(non_constant) > 0) {
cli::cli_abort(
"Aesthetics can not vary along a ribbon: {.field {.and non_constant}}."
"Aesthetics can not vary along a ribbon: {.and {.field {non_constant}}}."
)
}
if (length(aes$fill) > 1 || length(aes$alpha) > 1) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/geom-ribbon.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Problem while converting geom to grob.
i Error occurred in the 1st layer.
Caused by error in `draw_group()`:
! Aesthetics can not vary along a ribbon.
! Aesthetics can not vary along a ribbon: linewidth.

---

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-geom-ribbon.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test_that("geom_ribbon() checks the aesthetics", {
geom_ribbon(aes(y = year, xmin = level - 5, xmax = level + 5), orientation = "x")
expect_snapshot_error(ggplotGrob(p))
p <- ggplot(huron) +
geom_ribbon(aes(year, ymin = level - 5, ymax = level + 5, fill = year))
geom_ribbon(aes(year, ymin = level - 5, ymax = level + 5, linewidth = year))
expect_snapshot_error(ggplotGrob(p))

expect_snapshot_error(geom_ribbon(aes(year, ymin = level - 5, ymax = level + 5), outline.type = "test"))
Expand Down

0 comments on commit 62555b0

Please sign in to comment.