io.hypertrack.net.HyperTrackException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hypertrack-java Show documentation
Show all versions of hypertrack-java Show documentation
A Java wrapper for the HyperTrack API https://hypertrack.io
package io.hypertrack.net;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
/**
* Created by Arjun on 21/04/16.
*/
public class HyperTrackException extends Exception {
private int statusCode;
private String message;
public HyperTrackException(String message, int statusCode) {
super(message);
this.message = message;
this.statusCode = statusCode;
}
public static HyperTrackException parseResponse(HttpResponse response) throws IOException {
try {
int responseCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String responseString = EntityUtils.toString(entity, "UTF-8");
return new HyperTrackException(responseString, responseCode);
} catch (IOException e) {
throw new IOException("Unable to decode response");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy