Skip to content

Beginner question: error messages on decoding #317

Description

@leus

I've been programming with Scala for a few months now, but I still don't understand how (and if) can I get a better error messages from Argonaut. Currently, I have a codec and I use it as this:

val json: String = ...
val parsed = Parse.decodeEither[MyClass](json)
val checks = if (parsed.isRight) parsed.right.get
else sys.error("Unable to parse MyClass json: " + parsed.left)

However, I never get any useful error messages when I use this. All I get is java.lang.RuntimeException: Unable to parse MyClass json: LeftProjection(Left(String: CursorHistory(List()))).

What is the proper way to handle decoding errors?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions