rescript-json-combinators icon indicating copy to clipboard operation
rescript-json-combinators copied to clipboard

Expand decode error to include information about error

Open hellos3b opened this issue 1 year ago • 2 comments

Would be nice if the decode exception included information about the error instead of the error message, so the output could be formatted nicely to an end user

type path = array<string>
type expected = string
type actual = string

exception DecodeError(path, expected, actual)

The path property can point to where in an object or array that the error occured, so I can log a message like Expected "string" in Object.nested.field[0]

hellos3b avatar Jan 03 '23 18:01 hellos3b