scodec/scodec — pull request #27 by mpilquist (2014-10-10 03:32:02+00:00)
Title: Change error type from String to scodec.Err

By using an open-for-extension type as the error type, codecs are free to return domain specific errors and clients of such codecs can then dispatch based on the error type received.

This PR defines 2 subtypes of `Err` -- `General`, which wraps a string, and `InsufficientBits`, which indicates a decoding failure occurred due to the buffer being undersized.

This breaks source compatibility, although migration is fairly painless:
- when returning errors, instead of returning a `left(string)`, return a `left(Err(string))`
- when working with the result of encoding/decoding, call `err.messageWithContext` to get an equivalent `String`

Due to source compatibility breakage, I'd like to hear feedback from folks before merging. All feedback is appreciated but I'm tagging a few folks that I know have opinions. @pchiusano @djspiewak @stew @runarorama @timperrett

Note: I've considered making the error type parametrized (i.e., `Encoder[A, E]`, `Decoder[A, E]`, `Codec[A, E]`) but I'm not convinced that the benefits of the generality outweighs the added complexity in usage -- especially with implicit lookup. Additionally, the impacts to source compatibility are much, much higher.