Search in sources :

Example 1 with MockBadRequest

use of com.linkedin.restli.server.errors.MockBadRequest in project rest.li by linkedin.

the class MockValidationErrorHandler method updateErrorDetails.

@Override
public void updateErrorDetails(RestLiServiceException exception, Collection<Message> messages) {
    MockBadRequest badRequest = new MockBadRequest();
    MockInputErrorArray inputErrors = new MockInputErrorArray();
    for (Message message : messages) {
        if (message.isError() && message.getErrorDetails() instanceof MockInputError) {
            inputErrors.add((MockInputError) message.getErrorDetails());
        }
    }
    badRequest.setInputErrors(inputErrors);
    exception.setErrorDetails(badRequest);
    exception.setCode(ERROR_CODE);
}
Also used : MockInputError(com.linkedin.restli.server.errors.MockInputError) Message(com.linkedin.data.message.Message) MockInputErrorArray(com.linkedin.restli.server.errors.MockInputErrorArray) MockBadRequest(com.linkedin.restli.server.errors.MockBadRequest)

Example 2 with MockBadRequest

use of com.linkedin.restli.server.errors.MockBadRequest in project rest.li by linkedin.

the class MockValidationErrorHandler method updateErrorDetails.

@Override
public void updateErrorDetails(RestLiServiceException exception, Map<String, Collection<Message>> messages) {
    MockBadRequest badRequest = new MockBadRequest();
    MockInputErrorArray inputErrors = new MockInputErrorArray();
    for (Map.Entry<String, Collection<Message>> entry : messages.entrySet()) {
        for (Message message : entry.getValue()) {
            if (message.isError() && message.getErrorDetails() instanceof MockInputError) {
                MockInputError inputError = (MockInputError) message.getErrorDetails();
                inputError.setKey(entry.getKey());
                inputErrors.add(inputError);
            }
        }
    }
    badRequest.setInputErrors(inputErrors);
    exception.setErrorDetails(badRequest);
    exception.setCode(ERROR_CODE);
}
Also used : MockInputError(com.linkedin.restli.server.errors.MockInputError) Message(com.linkedin.data.message.Message) Collection(java.util.Collection) MockInputErrorArray(com.linkedin.restli.server.errors.MockInputErrorArray) MockBadRequest(com.linkedin.restli.server.errors.MockBadRequest) Map(java.util.Map)

Aggregations

Message (com.linkedin.data.message.Message)2 MockBadRequest (com.linkedin.restli.server.errors.MockBadRequest)2 MockInputError (com.linkedin.restli.server.errors.MockInputError)2 MockInputErrorArray (com.linkedin.restli.server.errors.MockInputErrorArray)2 Collection (java.util.Collection)1 Map (java.util.Map)1