Skip to content

Conversation

mirokuratczyk
Copy link

The motivation is to make decoding errors easier to trace.


For example, in the Haskell mongoDB library this call can result in a decoding error: Protocol.hs#L471.

The error would previously be:

Cannot decode byte '\\xc3': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream

With this change it is a bit easier to reason about:

Data.Binary.Get.runGet at position 172: Data.Bson.Binary.getString: decodeUtf8 failed: Cannot decode byte '\\xc3': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream\nCallStack (from HasCallStack):\n  error, called at libraries/binary/src/Data/Binary/Get.hs:351:5 in binary-0.8.5.1:Data.Binary.Get

Use decodeUtf8' so MonadFail can be utilized.
This makes decoding errors easier to trace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant