Skip to content
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

Enhance Deserializer's "Error. Unknown field" #911

Open
sthlm58 opened this issue Jan 17, 2024 · 0 comments · May be fixed by #935
Open

Enhance Deserializer's "Error. Unknown field" #911

sthlm58 opened this issue Jan 17, 2024 · 0 comments · May be fixed by #935

Comments

@sthlm58
Copy link

sthlm58 commented Jan 17, 2024

When having objectMapper->getDeserializer()->getConfig()->allowUnknownFields = false; and receiving an unknown field, the error message is a quite generic Error. Unknown field:

caret.setError("[oatpp::parser::json::mapping::Deserializer::readObject()]: Error. Unknown field", ERROR_CODE_OBJECT_SCOPE_UNKNOWN_FIELD);

I'd like to enhance it with the actual field name, something like Error. Unknown field 'foobar'.

However, the Caret class is storing only a const char* to an error message, and I'd need to store something like a std::string:

void Caret::setError(const char* errorMessage, v_int64 errorCode){

The actual question is: would you be open to receiving a PR with such an enhancement? And if so, what would be your preferred way of achieving it?

sthlm58 added a commit to sthlm58/oatpp that referenced this issue May 1, 2024
To enhance unknown field handling by adding the field's key to the error
message, the Caret now stores std::string error message.

Resolves oatpp#911
@sthlm58 sthlm58 linked a pull request May 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant