ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.85k stars 295 forks source link

Encode/decode errors are wrapped as strings #261

Closed akalin-keybase closed 6 years ago

akalin-keybase commented 6 years ago

One minor issue that we ran into when updating our fork was that the new error-wrapping behavior would cause tests to break. The tests would expect errors to be of a certain type, but since the returned error was wrapped, we'd have to change it to do string comparisons.

It's not too hard to change the wrapping to preserve the original error, and also to implement the causer interface from https://godoc.org/github.com/pkg/errors , which is the closest thing go has to a standard way of wrapping errors.

I implemented this in https://github.com/keybase/go-codec/pull/13 (with an example PR that uses it here: https://github.com/keybase/saltpack/pull/67 ). Would there be any interest in merging it upstream?

ugorji commented 6 years ago

Yes, will be happy to upstream this. Please create a CL that I can merge.

Please do not include the encode_test and decode_test.go files - I don't see the value in those tests.

akalin-keybase commented 6 years ago

Done! https://github.com/ugorji/go/pull/262