Example usage for org.apache.http.client HttpResponseException printStackTrace

List of usage examples for org.apache.http.client HttpResponseException printStackTrace

Introduction

In this page you can find the example usage for org.apache.http.client HttpResponseException printStackTrace.

Prototype

public void printStackTrace(PrintStream s) 

Source Link

Document

Prints this throwable and its backtrace to the specified print stream.

Usage

From source file:com.uber.jenkins.phabricator.uberalls.UberallsClient.java

public String getCoverage(String sha) {
    URIBuilder builder;/*  ww  w .j ava 2s.c o  m*/
    try {
        builder = getBuilder().setParameter("sha", sha).setParameter("repository", repository);

        HttpClient client = getClient();
        HttpMethod request = new GetMethod(builder.build().toString());
        int statusCode = client.executeMethod(request);

        if (statusCode != HttpStatus.SC_OK) {
            logger.info(TAG, "Call failed: " + request.getStatusLine());
            return null;
        }
        return request.getResponseBodyAsString();
    } catch (HttpResponseException e) {
        if (e.getStatusCode() != 404) {
            e.printStackTrace(logger.getStream());
        }
    } catch (Exception e) {
        e.printStackTrace(logger.getStream());
    }
    return null;
}