Skip to content

MissingFieldException should return class serialName #2958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nicktelford opened this issue Mar 20, 2025 · 1 comment
Open

MissingFieldException should return class serialName #2958

nicktelford opened this issue Mar 20, 2025 · 1 comment
Assignees
Labels

Comments

@nicktelford
Copy link

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.

@nicktelford nicktelford changed the title MissingFieldException should return serialName MissingFieldException should return serialName of affected class Mar 20, 2025
@nicktelford nicktelford changed the title MissingFieldException should return serialName of affected class MissingFieldException should return class serialName Mar 20, 2025
@sandwwraith
Copy link
Member

Great idea. This can be done as part of #2464

@sandwwraith sandwwraith self-assigned this Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants