com.baidu.discovery.client.exception.ServerStatusException Maven / Gradle / Ivy
package com.baidu.discovery.client.exception;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
/**
* @author Bowu Dong ([email protected])
*/
public class ServerStatusException extends RuntimeException {
private String message;
public ServerStatusException(String summary, HttpResponse response) {
try {
String body = EntityUtils.toString(response.getEntity());
String status = response.getStatusLine().toString();
message = String.format("%s, response=%s(%s)", summary, body, status);
} catch (IOException e) {
// omitted exception
}
}
public ServerStatusException(String summary, Object request, HttpResponse response) {
try {
String body = EntityUtils.toString(response.getEntity());
String status = response.getStatusLine().toString();
message = String.format("%s, request=%s response=%s(%s)", summary, request, body, status);
} catch (IOException e) {
// omitted exception
}
}
@Override
public String getMessage() {
return message;
}
}