daru icon indicating copy to clipboard operation
daru copied to clipboard

DataFrame#plot should provide more informative error message.

Open matugm opened this issue 6 years ago • 2 comments

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.

matugm avatar Jan 12 '19 19:01 matugm

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 avatar Jan 22 '19 12:01 Shekharrajak

We can have a custom error class for daru library.

Shekharrajak avatar Jan 22 '19 12:01 Shekharrajak