Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.messners.gitlab.api;
 
 import  javax.ws.rs.core.Response.StatusType;
 
This is the exception that will be thrown if any exception occurs while communicating with a GitLab API endpoint.

Author(s):
Greg Messner <greg@messners.com>
public class GitLabApiException extends Exception {
	private static final long serialVersionUID = 1L;
	private StatusType statusInfo;
	private int httpStatus;
	private String message;

Create a GitLabApiException instance based on the ClientResponse.

Parameters:
response
	public GitLabApiException (ClientResponse response) {
		super();
		 = response.getStatusInfo();
		 = response.getStatus();
		if (response.hasEntity()) {
			try {
				ErrorMessage errorMessage = response.getEntity(ErrorMessage.class);
				 = errorMessage.getMessage();
catch (Exception ignore) {}
		}		
	}


Create a GitLabApiException instance based on the exception.

Parameters:
e
		super(e);
	}


Get the message associated with the exception.

Returns:
the message associated with the exception
	public final String getMessage () {		
		return ( != null ?  : getReason());
	}	


Returns the HTTP status reason message, returns null if the causing error was not an HTTP related exception.

Returns:
the HTTP status reason message
	public final String getReason () {		
		return ( != null ? .getReasonPhrase() : null);
	}


Returns the HTTP status code that was the cause of the exception. returns 0 if the causing error was not an HTTP related exception.

Returns:
the HTTP status code, returns 0 if the causing error was not an HTTP related exception
	public final int getHttpStatus () {		
		return ();
	}
New to GrepCode? Check out our FAQ X