Skip to content

Commit e925263

Browse files
committed
unify mapping validation
1 parent e4bd1fc commit e925263

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

R/layer.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ validate_mapping <- function(mapping, call = caller_env()) {
209209
}
210210

211211
if (!is_mapping(mapping)) {
212-
msg <- "{.arg mapping} must be created by {.fn aes}."
212+
msg <- c(
213+
"{.arg mapping} must be created by {.fn aes}.",
214+
"x" = "You've supplied {.obj_type_friendly {mapping}}."
215+
)
213216
# Native pipe have higher precedence than + so any type of gg object can be
214217
# expected here, not just ggplot
215218
if (S7::S7_inherits(mapping, class_gg)) {

R/plot.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,8 @@ ggplot <- function(
116116
ggplot.default <-
117117
function(data, mapping = aes(), ..., environment = parent.frame()) {
118118

119-
if (!missing(mapping) && !is_mapping(mapping)) {
120-
cli::cli_abort(c(
121-
"{.arg mapping} must be created with {.fn aes}.",
122-
"x" = "You've supplied {.obj_type_friendly {mapping}}."
123-
))
119+
if (!missing(mapping)) {
120+
mapping <- validate_mapping(mapping)
124121
}
125122
if (missing(data)) {
126123
data <- NULL

0 commit comments

Comments
 (0)