File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ parseNoFields encoding json expectedTag =
319319 EncodeNested {} → do
320320 obj ← lmap JErr $ CA .decode jobject json
321321 val ←
322- ( Obj .lookup expectedTag obj # note ( JErr $ TypeMismatch ( " Expecting a property ` " <> expectedTag <> " ` " ))
322+ ( Obj .lookup expectedTag obj # note NoCase
323323 ) ∷ _ Json
324324 fields ← lmap JErr $ CA .decode CA .jarray val ∷ _ (Array Json )
325325 when (fields /= [] )
@@ -346,7 +346,7 @@ parseSingleField encoding json expectedTag = case encoding of
346346 EncodeNested { unwrapSingleArguments } → do
347347 obj ← lmap JErr $ CA .decode jobject json
348348 val ←
349- ( Obj .lookup expectedTag obj # note ( JErr $ TypeMismatch ( " Expecting a property ` " <> expectedTag <> " ` " ))
349+ ( Obj .lookup expectedTag obj # note NoCase
350350 ) ∷ _ Json
351351 if unwrapSingleArguments then
352352 pure val
@@ -472,8 +472,7 @@ instance gFlatCasesConstructorNoArg ∷
472472 let actualTag = Record .get (Proxy @tag) r ∷ String
473473
474474 when (actualTag /= name)
475- $ Left
476- (JErr $ TypeMismatch (" Expecting tag `" <> name <> " `, got `" <> actualTag <> " `" ))
475+ $ Left NoCase
477476
478477 pure (Constructor NoArguments )
479478
@@ -507,8 +506,7 @@ instance gFlatCasesConstructorSingleArg ∷
507506
508507 let actualTag = Record .get (Proxy @tag) r ∷ String
509508 when (actualTag /= name)
510- $ Left
511- (JErr $ TypeMismatch (" Expecting tag `" <> name <> " `, got `" <> actualTag <> " `" ))
509+ $ Left NoCase
512510
513511 let r' = Record .delete (Proxy @tag) r ∷ Record rf
514512 pure (Constructor (Argument r'))
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module Test.Sum where
33import Prelude
44
55import Control.Monad.Error.Class (liftEither )
6- import Data.Argonaut.Core (stringifyWithIndent )
6+ import Data.Argonaut.Core (stringify , stringifyWithIndent )
77import Data.Argonaut.Decode (parseJson )
88import Data.Bifunctor (lmap )
99import Data.Codec (decode , encode )
@@ -87,14 +87,14 @@ check ∷ ∀ a. Show a ⇒ Eq a ⇒ JsonCodec a → a → String → Effect Uni
8787check codec val expectEncoded = do
8888 let encodedStr = stringifyWithIndent 2 $ encode codec val
8989 when (encodedStr /= expectEncoded) $
90- throw (" check failed, expected: " <> expectEncoded <> " , got: " <> encodedStr)
90+ throw (" encode check failed, expected: " <> expectEncoded <> " , got: " <> encodedStr)
9191
9292 json ← liftEither $ lmap (show >>> error) $ parseJson encodedStr
9393
94- decoded ← liftEither $ lmap (show >>> error ) $ decode codec json
94+ decoded ← liftEither $ lmap (\err -> error ( " decode failed: " <> show err <> " JSON was: " <> stringify json) ) $ decode codec json
9595
9696 when (decoded /= val) $
97- throw (" check failed, expected: " <> show val <> " , got: " <> show decoded)
97+ throw (" decode check failed, expected: " <> show val <> " , got: " <> show decoded)
9898
9999main ∷ Effect Unit
100100main = do
You can’t perform that action at this time.
0 commit comments