Skip to content

Add type check to theme_set() #5252

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
Apr 11, 2023
Merged

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #3117.

It adds a type check to theme_set(), that is all it does.

Examples (backtraces omitted):

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

# Fine
theme_set(theme_bw())

# Oops forgot parentheses
theme_set(theme_bw)
#> Error in `theme_set()`:
#> ! `new` must be a <theme> object, not a function.

# Plain wrong input
theme_set("foo")
#> Error in `theme_set()`:
#> ! `new` must be a <theme> object, not the string "foo".

Created on 2023-03-29 with reprex v2.0.2

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please update the snapshots to include the new test

@teunbrand teunbrand merged commit 2e649bb into tidyverse:main Apr 11, 2023
@teunbrand teunbrand deleted the theme_set_errors branch April 11, 2023 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bad theme error message
2 participants