accodeing / fortnox-api

Gem that abstracts Fortnox's F3 API
GNU Lesser General Public License v3.0
9 stars 8 forks source link

Error information to end users #112

Open ehannes opened 7 years ago

ehannes commented 7 years ago

If you give the gem invalid data the gem throws an error, for instance:

Fortnox::API::Customer.new(customer_number: nil)
# => Fortnox::API::AttributeError: [Fortnox::API::Model::Order.new] nil (NilClass) has invalid type for :customer_number violates constraints (type?(String, nil) failed)>`

It does help us developers, but it is not much for the end user. We should try to improve this. Maybe there is some new feature in the Dry library that can help us out?

A simple improvement would be to add an attribute method to the Fortnox::API::AttributeError (or whatever error we are talking about) which returns the invalid attribute. Then we can at least tell the end user what attribute is invalid.