Skip to content

Use elaborateFailure in getFieldOptional' #52

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

Merged
merged 1 commit into from
Mar 1, 2019
Merged

Use elaborateFailure in getFieldOptional' #52

merged 1 commit into from
Mar 1, 2019

Conversation

LucianU
Copy link
Contributor

@LucianU LucianU commented Mar 1, 2019

What does this pull request do?

This changes getFieldOptional' to use elaborateFailure, just like its sister function getFieldOptional.

How should this be manually tested?

import Data.Argonaut.Decode (decodeJson)
import Data.Argonaut.Decode.Combinators (getFieldOptional')
import Data.Argonaut.Parser (jsonParser)
import Data.Maybe
import Data.Either
import Prelude

jsonParser "{\"age\": \"26\"}" >>= decodeJson >>= (\obj -> (obj `getFieldOptional'` "age") :: Either String (Maybe Int))

Without the change, the result is (Left "Value is not a Number").
With the change, the result is (Left "Failed to decode key 'age': Value is not a Number")

@thomashoneyman thomashoneyman merged commit 3be823e into purescript-contrib:master Mar 1, 2019
@thomashoneyman
Copy link
Contributor

thomashoneyman commented Mar 1, 2019

Thanks! This can be seen in release v5.1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants