Module

Codec.JSON.DecodeError

Package
purescript-codec-json
Repository
garyb/purescript-codec-json

#DecodeError Source

newtype DecodeError

Type for failures while decoding, a path to the point in the JSON that failure occurred, a message describing the problem, and a list of further causes for the failure.

Constructors

Instances

#DecodeErrorDetails Source

type DecodeErrorDetails = { causes :: Array DecodeError, message :: String, path :: Path }

#print Source

print :: DecodeError -> String

Prints an DecodeError as a somewhat readable error message.

#withPath Source

withPath :: (Path -> Path) -> DecodeError -> DecodeError

Updates the path for an error. The transformation is applied to the error itself along with its causes, recursively. This is intended for extending the path to elaborate on the location of errors from the top down.

#withContext Source

withContext :: String -> DecodeError -> DecodeError

Starts a new context for the error, pushing the current error into causes and providing a new message. This is useful for cases where you want to introduce a higher level error, adding information about domain types, for example.

#error Source

error :: Path -> String -> DecodeError

Constructs an error from a path and message (no further causes).

#basic Source

basic :: String -> DecodeError

Constructs a basic error from just a message.

#noValueFound Source

noValueFound :: Path -> DecodeError

Constructs an error with the message "No value found" and the specified path.