Added HTTP Code and Remote Message to Exception
This commit is contained in:
parent
74fda88b3f
commit
1fd5ff53e9
|
@ -109,8 +109,13 @@ public class Zenodo {
|
|||
|
||||
|
||||
private static <T> T check(Response resp, Class<T> clazz) throws ZenodoException{
|
||||
if(resp.getStatus()<200||resp.getStatus()>=300) {
|
||||
throw new ZenodoException("RESP STATUS IS "+resp.getStatus()+". Message : "+resp.readEntity(String.class));
|
||||
if(resp.getStatus()<200||resp.getStatus()>=300) {
|
||||
String remoteMessage=resp.readEntity(String.class);
|
||||
Integer httpCode=resp.getStatus();
|
||||
ZenodoException e=new ZenodoException("RESP STATUS IS "+httpCode+". Message : "+remoteMessage);
|
||||
e.setRemoteMessage(remoteMessage);
|
||||
e.setResponseHTTPCode(httpCode);
|
||||
throw e;
|
||||
}else {
|
||||
if(clazz==null) return null;
|
||||
String respString=resp.readEntity(String.class);
|
||||
|
|
|
@ -32,6 +32,24 @@ public class ZenodoException extends Exception{
|
|||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
private String remoteMessage=null;
|
||||
|
||||
private Integer responseHTTPCode=0;
|
||||
|
||||
public void setResponseHTTPCode(Integer responseHTTPCode) {
|
||||
this.responseHTTPCode = responseHTTPCode;
|
||||
}
|
||||
|
||||
public Integer getResponseHTTPCode() {
|
||||
return responseHTTPCode;
|
||||
}
|
||||
|
||||
public String getRemoteMessage() {
|
||||
return remoteMessage;
|
||||
}
|
||||
|
||||
public void setRemoteMessage(String remoteMessage) {
|
||||
this.remoteMessage = remoteMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue