Skip to content

Improved error messages for plot addition. #3600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions R/plot-construction.r
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ggplot_add <- function(object, plot, object_name) {
}
#' @export
ggplot_add.default <- function(object, plot, object_name) {
stop("Don't know how to add ", object_name, " to a plot", call. = FALSE)
stop("Can't add `", object_name, "` to a ggplot object.", call. = FALSE)
}
#' @export
ggplot_add.NULL <- function(object, plot, object_name) {
Expand All @@ -102,8 +102,9 @@ ggplot_add.data.frame <- function(object, plot, object_name) {
#' @export
ggplot_add.function <- function(object, plot, object_name) {
stop(
"Don't know how to add ", object_name, " to a plot. Did you mean ",
object_name, "()?", call. = FALSE
"Can't add `", object_name, "` to a ggplot object.\n",
"Did you forget to add parentheses, as in `",
object_name, "()`?", call. = FALSE
)
}
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/theme.r
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ plot_theme <- function(x, default = theme_get()) {
#' @keywords internal
add_theme <- function(t1, t2, t2name) {
if (!is.theme(t2)) {
stop("Don't know how to add ", t2name, " to a theme object",
stop("Can't add `", t2name, "` to a theme object.",
call. = FALSE)
}

Expand Down