on master help sign in
Update error message, remove redundant commented lines and empty lines.
9ca2259grdvnl
Data/Aeson/Types/FromJSON.hs+3−8
@@ -952,18 +952,15 @@ type ConName = String
952contextType :: TypeName -> Parser a -> Parser a
952contextType :: TypeName -> Parser a -> Parser a
953contextType = prependContext
953contextType = prependContext
954
954
955−
956−
957-- | Add the tagKey that will be looked up while building an ADT
955-- | Add the tagKey that will be looked up while building an ADT
958-- | Produce the error equivalent to
956-- | Produce the error equivalent to
959-- | Left "Error in $: parsing T failed, expected an object with keys "tag" and
957-- | Left "Error in $: parsing T failed, expected an object with keys "tag" and
960-- | "contents", where "tag" i-- |s associated to one of ["Foo", "Bar"],
958-- | "contents", where "tag" i-- |s associated to one of ["Foo", "Bar"],
961-- | The parser returned error was: could not find key "tag"
959-- | The parser returned error was: could not find key "tag"
962contextTag :: Text -> [String] -> Parser a -> Parser a
960contextTag :: Text -> [String] -> Parser a -> Parser a
963−contextTag tagKey cnames = prependFailure
961+contextTag tagKey cnames = modifyFailure (\_ ->
964− ("expected an object with key \"" ++ unpack tagKey ++
962+ ("expected Object with key \"" ++ unpack tagKey ++ "\"" ++
965− "\" where \"tag\" is associated to one of " ++ show cnames ++
963+ " associated to one of " ++ show cnames ++ "."))
966− ". The parser returned error was: ")
967
964
968-- | Add the name of the constructor being parsed to a parser's error messages.
965-- | Add the name of the constructor being parsed to a parser's error messages.
969contextCons :: ConName -> TypeName -> Parser a -> Parser a
966contextCons :: ConName -> TypeName -> Parser a -> Parser a
@@ -1163,8 +1160,6 @@ parseNonAllNullarySum p@(tname :* opts :* _) =
1163 "expected tag field to be one of " ++ show cnames ++
1160 "expected tag field to be one of " ++ show cnames ++
1164 ", but found tag " ++ show tag
1161 ", but found tag " ++ show tag
1165 cnames_ = unTagged2 (constructorTags (constructorTagModifier opts) :: Tagged2 f [String])
1162 cnames_ = unTagged2 (constructorTags (constructorTagModifier opts) :: Tagged2 f [String])
1166− --cname_ = conName (undefined :: M1 _i c _f _p)
1167− -- forall f a. ConstructorNames f
1168
1163
1169 ObjectWithSingleField ->
1164 ObjectWithSingleField ->
1170 withObject tname $ \obj -> case H.toList obj of
1165 withObject tname $ \obj -> case H.toList obj of
tests/golden/generic.expected+1−1
@@ -10,7 +10,7 @@ Error in $: parsing Types.SomeType(Unary) failed, key "contents" not present
10Error in $: parsing Types.SomeType(Record) failed, key "testone" not present
10Error in $: parsing Types.SomeType(Record) failed, key "testone" not present
11Error in $.testone: parsing Double failed, unexpected Boolean
11Error in $.testone: parsing Double failed, unexpected Boolean
12Error in $.tag: parsing Types.SomeType failed, expected tag field to be one of ["nullary","unary","product","record","list"], but found tag "X"
12Error in $.tag: parsing Types.SomeType failed, expected tag field to be one of ["nullary","unary","product","record","list"], but found tag "X"
13−Error in $: parsing Types.SomeType failed, expected an object with key "tag" where "tag" is associated to one of ["nullary","unary","product","record","list"]. The parser returned error was: key "tag" not present
13+Error in $: parsing Types.SomeType failed, expected Object with key "tag" associated to one of ["nullary","unary","product","record","list"].
14Error in $: parsing Types.SomeType failed, expected Object, but encountered Array
14Error in $: parsing Types.SomeType failed, expected Object, but encountered Array
15SomeType (single-field)
15SomeType (single-field)
16Error in $.unary: parsing Int failed, expected Number, but encountered Object
16Error in $.unary: parsing Int failed, expected Number, but encountered Object