use of com.netflix.conductor.common.validation.ErrorResponse in project conductor by Netflix.
the class ValidationExceptionMapper method toErrorResponse.
private static ErrorResponse toErrorResponse(ValidationException ve) {
if (ve instanceof ConstraintViolationException) {
return constraintViolationExceptionToErrorResponse((ConstraintViolationException) ve);
} else {
ErrorResponse result = new ErrorResponse();
result.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
result.setMessage(ve.getMessage());
return result;
}
}
use of com.netflix.conductor.common.validation.ErrorResponse in project conductor by Netflix.
the class ValidationExceptionMapper method constraintViolationExceptionToErrorResponse.
private static ErrorResponse constraintViolationExceptionToErrorResponse(ConstraintViolationException exception) {
ErrorResponse errorResponse = new ErrorResponse();
errorResponse.setStatus(Response.Status.BAD_REQUEST.getStatusCode());
errorResponse.setMessage("Validation failed, check below errors for detail.");
List<ValidationError> validationErrors = new ArrayList<>();
exception.getConstraintViolations().forEach(e -> validationErrors.add(new ValidationError(getViolationPath(e), e.getMessage(), getViolationInvalidValue(e.getInvalidValue()))));
errorResponse.setValidationErrors(validationErrors);
return errorResponse;
}
use of com.netflix.conductor.common.validation.ErrorResponse in project conductor by Netflix.
the class ClientBase method handleUniformInterfaceException.
private void handleUniformInterfaceException(UniformInterfaceException exception, URI uri) {
ClientResponse clientResponse = exception.getResponse();
if (clientResponse == null) {
throw new ConductorClientException(String.format("Unable to invoke Conductor API with uri: %s", uri));
}
try {
if (clientResponse.getStatus() < 300) {
return;
}
String errorMessage = clientResponse.getEntity(String.class);
logger.error("Unable to invoke Conductor API with uri: {}, unexpected response from server: statusCode={}, responseBody='{}'.", uri, clientResponse.getStatus(), errorMessage);
ErrorResponse errorResponse;
try {
errorResponse = objectMapper.readValue(errorMessage, ErrorResponse.class);
} catch (IOException e) {
throw new ConductorClientException(clientResponse.getStatus(), errorMessage);
}
throw new ConductorClientException(clientResponse.getStatus(), errorResponse);
} catch (ConductorClientException e) {
throw e;
} catch (ClientHandlerException e) {
handleClientHandlerException(e, uri);
} catch (RuntimeException e) {
handleRuntimeException(e, uri);
} finally {
clientResponse.close();
}
}
Aggregations