Commit 2b2aaf0e authored by Greg Messner's avatar Greg Messner
Browse files

Initial check-in.

parent 1d68180a
package com.messners.gitlab.api;
import javax.ws.rs.core.Response.StatusType;
import com.messners.gitlab.api.models.ErrorMessage;
import com.sun.jersey.api.client.ClientResponse;
public class GitLabApiException extends Exception {
private static final long serialVersionUID = 1L;
private StatusType statusInfo;
private String message;
/**
*
* @param response
*/
public GitLabApiException (ClientResponse response) {
super();
statusInfo = response.getStatusInfo();
if (response.hasEntity()) {
try {
ErrorMessage errorMessage = response.getEntity(ErrorMessage.class);
message = errorMessage.getMessage();
} catch (Exception ignore) {}
}
}
public GitLabApiException (Exception e) {
super(e);
message = e.getMessage();
}
/**
*
*/
@Override
public final String getMessage () {
return (message != null ? message : statusInfo.getReasonPhrase());
}
/**
*
* @return
*/
public final String getReason () {
return (statusInfo.getReasonPhrase());
}
/**
*
* @return
*/
public final int getHttpStatus () {
return (statusInfo.getStatusCode());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment