Skip to content

Add type check to theme_set() - #5252

Merged
teunbrand merged 2 commits into
tidyverse:mainfrom
teunbrand:theme_set_errors
Apr 11, 2023
Merged

teunbrand merged 2 commits into
tidyverse:mainfrom
teunbrand:theme_set_errors

Conversation

@teunbrand

Copy link
Copy Markdown
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

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Member

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