Skip to content

MissingFieldException should return class serialNameΒ #2958

Open
@nicktelford

Description

@nicktelford

MissingFieldException currently provides the names of the missingFields, but it does not provide the name of the class/type the fields were missing from, despite being a constructor parameter.

Currently, the serialName of the affected type is provided to the constructor, and used to construct the error message. This should be made available as a field on the MissingFieldException, to enable programmatic determination of the source of the error.

This is particularly useful when deserializing into a class hierarchy, as the name of the missing field alone may be ambiguous, and exception handlers may need to know the type of the affected class to determine the best course of action.

Adding the serialName as a field should be a trivial addition, since it's already available in the constructor.

It might also be useful to go further, and provide a "path" to the missing fields in the JSON AST, which would provide exception handlers with even more information, which could be especially useful in error messages.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions