File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,14 @@ gDecodeJson' signature json = case signature of
51
51
sp <- gDecodeJson' (val unit) pf
52
52
pure { recLabel: lbl, recValue: const sp }
53
53
SigProd typeConstr alts -> do
54
- let decodingErr msg = " When decoding " ++ typeConstr ++ " " ++ msg
54
+ let decodingErr msg = " When decoding a " ++ typeConstr ++ " : " ++ msg
55
55
jObj <- mFail (decodingErr " expected an object" ) (toObject json)
56
- tag <- mFail (decodingErr " 'tag' string property is missing" ) (toString =<< M .lookup " tag" jObj)
56
+ tagJson <- mFail (decodingErr " 'tag' property is missing" ) (M .lookup " tag" jObj)
57
+ tag <- mFail (decodingErr " 'tag' property is not a string" ) (toString tagJson)
57
58
case find ((tag ==) <<< _.sigConstructor) alts of
58
- Nothing -> Left (" '" <> tag <> " ' isn't a valid constructor" )
59
+ Nothing -> Left (decodingErr ( " '" <> tag <> " ' isn't a valid constructor" ) )
59
60
Just { sigValues: sigValues } -> do
60
- vals <- mFail " 'values' array is missing" (toArray =<< M .lookup " values" jObj)
61
+ vals <- mFail (decodingErr " 'values' array is missing" ) (toArray =<< M .lookup " values" jObj)
61
62
sps <- zipWithA (\k -> gDecodeJson' (k unit)) sigValues vals
62
63
pure (SProd tag (const <$> sps))
63
64
where
You can’t perform that action at this time.
0 commit comments