Search in sources :

Example 1 with ValidationErrorData

use of dev.hilla.exception.EndpointValidationException.ValidationErrorData in project flow by vaadin.

the class EndpointInvoker method getInvalidEndpointParametersException.

private EndpointValidationException getInvalidEndpointParametersException(String methodName, String endpointName, Map<String, String> deserializationErrors, Set<ConstraintViolation<Object>> constraintViolations) {
    List<ValidationErrorData> validationErrorData = new ArrayList<>(deserializationErrors.size() + constraintViolations.size());
    for (Map.Entry<String, String> deserializationError : deserializationErrors.entrySet()) {
        String message = String.format("Unable to deserialize an endpoint method parameter into type '%s'", deserializationError.getValue());
        validationErrorData.add(new ValidationErrorData(message, deserializationError.getKey()));
    }
    validationErrorData.addAll(createBeanValidationErrors(constraintViolations));
    String message = String.format("Validation error in endpoint '%s' method '%s'", endpointName, methodName);
    return new EndpointValidationException(message, validationErrorData);
}
Also used : EndpointValidationException(dev.hilla.exception.EndpointValidationException) ArrayList(java.util.ArrayList) ValidationErrorData(dev.hilla.exception.EndpointValidationException.ValidationErrorData) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

EndpointValidationException (dev.hilla.exception.EndpointValidationException)1 ValidationErrorData (dev.hilla.exception.EndpointValidationException.ValidationErrorData)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1