rmehner/badgeville — pull request #3 by mrnugget (2012-06-11 12:27:24+00:00)
Title: Error handling: move responsibility to single error classes

I rewrote some parts of `errors.rb` in order to make a first step towards better error handling:

* The single Error classes now define their own messages and just take an error as argument.

* `Badgeville::Error` takes care of adding a `[Badgeville]` tag to the messages of its child classes.

* Move the responsibility of handling with the original errors into the single error classes: the single classes (e.g. `ParseError`) decide if they need to have an `response` attribute or not. In the case of `ParseError` it doesn't make much sense having an `response` attribute. But for `NotFound` it does make sense, since a `404` error can still give a response.

* The deprecated `BadgevilleError` still has `data` and `code` attributes, so it should still work fine with the deprecated client methods.

* Single errors being responsible for their `message` and `response` attributes is a first step towards better error handling, since it's possible to tailor the errors to better reflect the actual Badgeville errors and responses.

So, what do you think? :) I'm not really sure if this is the way to go in the specs. But it does serve the purpose and tests for the indivual attributes of the errors.