SciRuby / daru

Data Analysis in RUby
BSD 2-Clause "Simplified" License
1.03k stars 139 forks source link

DataFrame#plot should provide more informative error message. #479

Open matugm opened 5 years ago

matugm commented 5 years ago

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.

Shekharrajak commented 5 years ago

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.

Shekharrajak commented 5 years ago

We can have a custom error class for daru library.