t6d / smart_properties

Ruby accessors on steroids
MIT License
177 stars 20 forks source link

InvalidValueError doesn't give enough information #42

Closed marutypes closed 8 years ago

marutypes commented 8 years ago

At the moment SmartProperties::InvalidValueError comes with messages such as

UiIcon does not accept 10 as a value for the property size

This can be very unhelpful for consumers. It would be better to output information about the set of accepted values, or the path of the proc that determines them.

eg.

UiIcon does not accept 10 as a value for the property size. Property only accepts [16, 32, 64]
SheepWidget does not accept :big as a value for the property size. Property only accepts [Numeric]
ButtonWidget does not accept :excited for property type. Property only accepts values evaluated as truthy by Proc defined at mycode/src/widgets/button_widget.rb at line 35.

I'm not sure about the wording on some of these cases, but I think it gets the intention across.