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

Throw better exception on wrong dynamic_templates syntax #51783

Merged
merged 6 commits into from
Feb 4, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ protected boolean processField(RootObjectMapper.Builder builder, String fieldNam
}
]
*/
if (!(fieldNode instanceof List)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small style nit: can you use ((fieldNode instanceof List) == false) instead? We prefer that kind of more verbose state to the negate operator for better readability throughout the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbuescher ok I will fix for you suggest

throw new MapperParsingException("Dynamic template syntax error");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to provide some more information the user what went wrong. In this case it would be great to tell the user know that dynamic_templates expects an array of named objects or something along those lines.

}
List<?> tmplNodes = (List<?>) fieldNode;
List<DynamicTemplate> templates = new ArrayList<>();
for (Object tmplNode : tmplNodes) {
Expand Down