Skip to content

Commit 2a5c700

Browse files
committed
improve information in error message
1 parent bd5418f commit 2a5c700

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

R/facet-.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Facet <- ggproto("Facet", NULL,
161161
params
162162
)
163163

164-
# Draw individual panels, then call `$draw_panels()` method to
164+
# Draw individual panels, then call `$draw_panels()` method to
165165
# assemble into gtable
166166
lapply(seq_along(panels[[1]]), function(i) {
167167
panel <- lapply(panels, `[[`, i)
@@ -185,10 +185,12 @@ Facet <- ggproto("Facet", NULL,
185185
if (space$x && space$y) {
186186
aspect_ratio <- aspect_ratio %||% coord$ratio
187187
} else if (free$x || free$y) {
188-
cli::cli_abort(
189-
"{.fn {snake_class(self)}} can't use free scales with \\
190-
{.fn {snake_class(coord)}}."
191-
)
188+
msg <- paste0("{.fn {snake_class(self)}} can't use free scales with ",
189+
"{.fn {snake_class(coord)}}")
190+
if (!is.null(coord$ratio)) {
191+
msg <- paste0(msg, " with a fixed {.arg ratio} argument")
192+
}
193+
cli::cli_abort(paste0(msg, "."))
192194
}
193195
}
194196

tests/testthat/_snaps/facet-layout.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434
---
3535

36-
`facet_wrap()` can't use free scales with `coord_fixed()`.
36+
`facet_wrap()` can't use free scales with `coord_cartesian()` with a fixed `ratio` argument.
3737

3838
# facet_grid throws errors at bad layout specs
3939

40-
`facet_grid()` can't use free scales with `coord_fixed()`.
40+
`facet_grid()` can't use free scales with `coord_cartesian()` with a fixed `ratio` argument.
4141

4242
---
4343

0 commit comments

Comments
 (0)