Skip to content

[FEATURE]: Improve C++ std::runtime_error message for failed enum deserialization #2796

Open
@cconverse711

Description

@cconverse711

Currently, a vague exception message is provided ("Input JSON does not conform to schema!"), which leaves no useful guidance for what part of the JSON does not conform. Providing the enum name, and possibly listing the possible options would help users fix the non-conformant json.

Context (Input, Language)

Input Format: schema
Output Language: C++

Description

I would like to more easily indicate to the user what part of the JSON failed to deserialize. For example, if using a json config file for an application, it would be helpful to indicate which part is does not conform to the schema, so that they can fix it more easily.

Current Behaviour / Output

std::runtime_error is raised with message Input JSON does not conform to schema!

Proposed Behaviour / Output

std::runtime_error raised with message like Cannot deserialize to enumeration "FooBar".
It may also be helpful to include a comma-separate list of the actual allowed enum options, but that may be unwieldy if there are many.

Solution

Adjust the exception error message to include enumeration name, and possibly enum options.

Alternatives

Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions