Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decodeUtf8 #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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