Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Data/Argonaut/Decode/Error.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- | Originally implemented in:
-- | Originally implemented in:
-- | https://github.com/garyb/purescript-codec-argonaut
module Data.Argonaut.Decode.Error where

Expand All @@ -15,6 +15,7 @@ data JsonDecodeError
| AtKey String JsonDecodeError
| Named String JsonDecodeError
| MissingValue
| CustomError String

derive instance eqJsonDecodeError :: Eq JsonDecodeError
derive instance ordJsonDecodeError :: Ord JsonDecodeError
Expand All @@ -28,6 +29,7 @@ instance showJsonDecodeError :: Show JsonDecodeError where
AtKey k e -> "(AtKey " <> show k <> " " <> show e <> ")"
Named s e -> "(Named " <> show s <> " " <> show e <> ")"
MissingValue -> "MissingValue"
CustomError e -> "(CustomError " <> e <> ")"

-- | Prints a `JsonDecodeError` as a readable error message.
printJsonDecodeError :: JsonDecodeError -> String
Expand All @@ -41,3 +43,4 @@ printJsonDecodeError err =
AtKey key inner -> " At object key \'" <> key <> "\':\n" <> go inner
Named name inner -> " Under '" <> name <> "':\n" <> go inner
MissingValue -> " No value was found."
CustomError e -> " " <> e