Search in sources :

Example 1 with BadRequest

use of com.google.rpc.BadRequest in project titus-control-plane by Netflix.

the class TestStreamObserver method exceptionMapper.

private RuntimeException exceptionMapper(Throwable error) {
    if (error instanceof StatusRuntimeException) {
        StatusRuntimeException e = (StatusRuntimeException) error;
        String errorMessage = "GRPC status " + e.getStatus() + ": " + e.getTrailers().get(ErrorResponses.KEY_TITUS_ERROR_REPORT);
        Optional<BadRequest> badRequest = GrpcClientErrorUtils.getDetail(e, BadRequest.class);
        if (badRequest.isPresent()) {
            return new RuntimeException(errorMessage + ". Invalid field values: " + badRequest, error);
        }
        return new RuntimeException(errorMessage, error);
    }
    return new RuntimeException(error.getMessage(), error);
}
Also used : BadRequest(com.google.rpc.BadRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) StatusRuntimeException(io.grpc.StatusRuntimeException)

Aggregations

BadRequest (com.google.rpc.BadRequest)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1