Fix cryptic error messages caused by missing aesthetics #2754
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #2637 ; Fixes #2706
This is a minor change switching the order of calls in
layer$compute_geom_1
to callcheck_required_aesthetics()
beforegeom*$setup_data()
in order to catch missing aesthetics and offer informative error messages.This fixes cryptic error messages from
GeomArea
,GeomCol
,GeomCrossbar
,GeomErrorbar
,GeomErrorbarh
,GeomLine
,GeomRaster
,GeomSpoke
, andGeomTile
.From my analysis this should have no adverse side effects.
The other Geoms' were appropriately handled for one of two reasons:
setup_data()
functions simply returndata
unchanged and therefore did not call any potentially missing aesthetics which caused the cryptic errors beforecheck_required_aesthetics
was originally called (e.g. GeomPoint, GeomText, GeomRibbon, ...).Or,
stat_*$compute_layer()
and the appropriate warning returned earlier (e.g. GeomBoxplot, GeomSmooth, GeomHex, GeomBar...).All tests pass and I have checked the new behaviour of all Geoms, but I am open to considering other ways to test this or potential side effects I have not foreseen. I was unsure if the NEWS bullet was warranted but as it fixes two user facing issues I figured it was potentially useful.