Search in sources :

Example 1 with BindValidationException

use of org.springframework.boot.context.properties.bind.validation.BindValidationException in project spring-boot by spring-projects.

the class BindValidationFailureAnalyzer method getBindValidationExceptionDetails.

private ExceptionDetails getBindValidationExceptionDetails(Throwable rootFailure) {
    BindValidationException validationException = findCause(rootFailure, BindValidationException.class);
    if (validationException != null) {
        BindException target = findCause(rootFailure, BindException.class);
        List<ObjectError> errors = validationException.getValidationErrors().getAllErrors();
        return new ExceptionDetails(errors, target, validationException);
    }
    org.springframework.validation.BindException bindException = findCause(rootFailure, org.springframework.validation.BindException.class);
    if (bindException != null) {
        List<ObjectError> errors = bindException.getAllErrors();
        return new ExceptionDetails(errors, bindException.getTarget(), bindException);
    }
    return null;
}
Also used : BindValidationException(org.springframework.boot.context.properties.bind.validation.BindValidationException) ObjectError(org.springframework.validation.ObjectError) BindException(org.springframework.boot.context.properties.bind.BindException)

Aggregations

BindException (org.springframework.boot.context.properties.bind.BindException)1 BindValidationException (org.springframework.boot.context.properties.bind.validation.BindValidationException)1 ObjectError (org.springframework.validation.ObjectError)1