Search in sources :

Example 76 with RestException

use of com.linkedin.r2.message.rest.RestException in project incubator-gobblin by apache.

the class R2Client method sendRequestImpl.

@Override
public RestResponse sendRequestImpl(RestRequest request) throws IOException {
    Future<RestResponse> responseFuture = client.restRequest(request);
    RestResponse response;
    try {
        response = responseFuture.get();
    } catch (InterruptedException | ExecutionException e) {
        // The service may choose to throw an exception as a way to report error
        Throwable t = e.getCause();
        if (t != null && t instanceof RestException) {
            response = ((RestException) t).getResponse();
        } else {
            throw new IOException(e);
        }
    }
    return response;
}
Also used : RestResponse(com.linkedin.r2.message.rest.RestResponse) RestException(com.linkedin.r2.message.rest.RestException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

RestException (com.linkedin.r2.message.rest.RestException)70 RestResponse (com.linkedin.r2.message.rest.RestResponse)61 Test (org.testng.annotations.Test)51 RestRequest (com.linkedin.r2.message.rest.RestRequest)46 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)42 ExecutionException (java.util.concurrent.ExecutionException)30 URI (java.net.URI)24 RequestContext (com.linkedin.r2.message.RequestContext)23 Callback (com.linkedin.common.callback.Callback)19 ByteString (com.linkedin.data.ByteString)18 FilterRequestContext (com.linkedin.restli.server.filter.FilterRequestContext)16 BeforeTest (org.testng.annotations.BeforeTest)15 RestResponseBuilder (com.linkedin.r2.message.rest.RestResponseBuilder)14 URISyntaxException (java.net.URISyntaxException)14 StreamResponse (com.linkedin.r2.message.stream.StreamResponse)13 MultiPartMIMEFullReaderCallback (com.linkedin.multipart.utils.MIMETestUtils.MultiPartMIMEFullReaderCallback)12 SinglePartMIMEFullReaderCallback (com.linkedin.multipart.utils.MIMETestUtils.SinglePartMIMEFullReaderCallback)12 AfterTest (org.testng.annotations.AfterTest)12 StreamException (com.linkedin.r2.message.stream.StreamException)11 StreamRequest (com.linkedin.r2.message.stream.StreamRequest)9