Open botanize opened 5 months ago
Thanks for the report! If this is a request for better messages, it is probably better to appeal to {scales} to improve the message. ggplot2 has little control over the messages the packages it depend on throw.
I would like better messages, but I think the best way of doing that would be to check that the inputs received by the function are the correct type (as stated by function documentation), instead of passing them blindly to other functions unknown. In this case, it's because I passed a function to the wrong breaks parameter (date_breaks
instead of breaks
). While I guess {scales} could check inputs as well, this does seem like something that should happen in datetime_scales
. Oddly, I see that the default value for the date_breaks
parameter in datetime_scales
is waiver()
, clearly not a character string.
datetime_scales
accepts any argument type fordate_breaks
anddate_minor_breaks
, but the parameter documentation claims it only accepts character strings. It's somewhat easy to accidentally supply custom date breaks usingscales::breaks_width
to the wrong parameter (date_breaks
instead ofbreaks
), after all, you're defining date-breaks either way.I expected an error that the date_breaks parameter had the wrong type, instead I got the unhelpful:
Error in strsplit(unitspec, " ") : non-character argument
.