daru
daru copied to clipboard
DataFrame#plot should provide more informative error message.
As mentioned in #478 I find that some error messages could be improved to provide a better user experience.
For example:
require 'daru'
df = Daru::DataFrame.new(
{ "Row 1" => [1, 2, 3],
"Row 2" => [3, 4, 5]
}
)
df.plot(type: :bar, x: "Row 1")
Results in:
NoMethodError (undefined method `to_sym' for nil:NilClass)
But this error doesn't help the user understand that there is a missing y
value.
There are other errors like these where missing or incorrect data leads into an exception.
Another Example:
If you don't provide a plot type at all you get "NameError (wrong constant name)"
. It may be more helpful to provide a list of valid plot types in this case.
Yes! There should be begin
, rescue
block to handle any kind of error coming from another gem. It must throw an error with the correct input type.
We can have a custom error class for daru library.