Search in sources :

Example 1 with ConstraintDefinitionException

use of jakarta.validation.ConstraintDefinitionException in project resteasy by resteasy.

the class ResteasyViolationExceptionMapper method toResponse.

public Response toResponse(ValidationException exception) {
    if (exception instanceof ConstraintDefinitionException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof ConstraintDeclarationException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof GroupDefinitionException) {
        return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
    }
    if (exception instanceof ResteasyViolationException) {
        ResteasyViolationException resteasyViolationException = ResteasyViolationException.class.cast(exception);
        Exception e = resteasyViolationException.getException();
        if (e != null) {
            return buildResponse(unwrapException(e), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
        } else if (resteasyViolationException.getReturnValueViolations().size() == 0) {
            return buildViolationReportResponse(resteasyViolationException, Status.BAD_REQUEST);
        } else {
            return buildViolationReportResponse(resteasyViolationException, Status.INTERNAL_SERVER_ERROR);
        }
    }
    return buildResponse(unwrapException(exception), MediaType.TEXT_PLAIN, Status.INTERNAL_SERVER_ERROR);
}
Also used : GroupDefinitionException(jakarta.validation.GroupDefinitionException) ConstraintDeclarationException(jakarta.validation.ConstraintDeclarationException) ResteasyViolationException(org.jboss.resteasy.api.validation.ResteasyViolationException) ResteasyViolationException(org.jboss.resteasy.api.validation.ResteasyViolationException) ConstraintDeclarationException(jakarta.validation.ConstraintDeclarationException) ConstraintDefinitionException(jakarta.validation.ConstraintDefinitionException) ValidationException(jakarta.validation.ValidationException) GroupDefinitionException(jakarta.validation.GroupDefinitionException) ConstraintDefinitionException(jakarta.validation.ConstraintDefinitionException)

Aggregations

ConstraintDeclarationException (jakarta.validation.ConstraintDeclarationException)1 ConstraintDefinitionException (jakarta.validation.ConstraintDefinitionException)1 GroupDefinitionException (jakarta.validation.GroupDefinitionException)1 ValidationException (jakarta.validation.ValidationException)1 ResteasyViolationException (org.jboss.resteasy.api.validation.ResteasyViolationException)1