yjunechoe/ggtrace

Make inheritance error more informative

Closed this issue · 3 comments

> ggtrace_inspect_n(p, StatCount$compute_panel)
Error:
! Method 'compute_panel' is not defined for `StatCount`
Check inheritance with `get_method(StatCount$compute_panel, inherit = TRUE)`

Should be more like:

> ggtrace_inspect_n(p, StatCount$compute_panel)
Error:
! Method 'compute_panel' is not defined for `StatCount`
Did you mean the inherited method `Stat$compute_panel`?

Requires distinguishing between inherited-not-defined vs. not-defined

Or ... make it a warning not an error; just grab the right method internally and say so

Balances the goal of making people learn how ggproto works through exposure but also not make the function require knowledge about ggproto

Actually that can lead to odd behavior, like inspecting StatBoxplot$compute_layer will work in geom_bar() b/c it fetches Stat$compute_layer which StatCount also inherits ...

redirects to get_method_inheritance for now - 602f2db

possibly consider augmenting error message with suggestion ("did you mean ...?")