Skip to content

Cannot handle UnrecognizedPropertyException using this code #1

@iamsamarsharma

Description

@iamsamarsharma

Added property spring.jackson.deserialization.fail-on-unknown-properties=true

Which throws

UnrecognizedPropertyException

tried to capture this excetion via below code

@ExceptionHandler(UnrecognizedPropertyException.class)
public ResponseEntity<Map<String, List>> handleUnrecognizedPropertyException(UnrecognizedPropertyException ex) {
List errors = Collections.singletonList(ex.getMessage());
return new ResponseEntity<>(getErrorsMap(errors), new HttpHeaders(), HttpStatus.NOT_FOUND);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions