on master help sign in
Update error message, remove redundant commented lines and empty lines.
commit9ca2259cd00962d57f4bbdd0b63cb8284959ea24 authorgrdvnl <grdvnl@gmail.com> dateSat 12 Oct 2019, 23:13 (7 years ago) parent3fc8c45
2 files changed+4−9
Data/Aeson/Types/FromJSON.hs+3−8 tests/golden/generic.expected+1−1
Data/Aeson/Types/FromJSON.hs+3−8
@@ -952,18 +952,15 @@ type ConName = String
952952contextType :: TypeName -> Parser a -> Parser a
953953contextType = prependContext
954954
955−
956−
957955-- | Add the tagKey that will be looked up while building an ADT
958956-- | Produce the error equivalent to
959957-- | Left "Error in $: parsing T failed, expected an object with keys "tag" and
960958-- | "contents", where "tag" i-- |s associated to one of ["Foo", "Bar"],
961959-- | The parser returned error was: could not find key "tag"
962960contextTag :: Text -> [String] -> Parser a -> Parser a
963−contextTag tagKey cnames = prependFailure
964− ("expected an object with key \"" ++ unpack tagKey ++
965− "\" where \"tag\" is associated to one of " ++ show cnames ++
966− ". The parser returned error was: ")
961+contextTag tagKey cnames = modifyFailure (\_ ->
962+ ("expected Object with key \"" ++ unpack tagKey ++ "\"" ++
963+ " associated to one of " ++ show cnames ++ "."))
967964
968965-- | Add the name of the constructor being parsed to a parser's error messages.
969966contextCons :: ConName -> TypeName -> Parser a -> Parser a
@@ -1163,8 +1160,6 @@ parseNonAllNullarySum p@(tname :* opts :* _) =
11631160 "expected tag field to be one of " ++ show cnames ++
11641161 ", but found tag " ++ show tag
11651162 cnames_ = unTagged2 (constructorTags (constructorTagModifier opts) :: Tagged2 f [String])
1166− --cname_ = conName (undefined :: M1 _i c _f _p)
1167− -- forall f a. ConstructorNames f
11681163
11691164 ObjectWithSingleField ->
11701165 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
1010Error in $: parsing Types.SomeType(Record) failed, key "testone" not present
1111Error in $.testone: parsing Double failed, unexpected Boolean
1212Error 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"].
1414Error in $: parsing Types.SomeType failed, expected Object, but encountered Array
1515SomeType (single-field)
1616Error in $.unary: parsing Int failed, expected Number, but encountered Object