Share via


GraphServiceException Class

public class GraphServiceException
extends ClientException

An exception from the Graph service

Field Summary

Modifier and Type Field and Description
static final int INTERNAL_SERVER_ERROR

The internal server error threshold defined by the HTTP protocol

protected static final int MAX_BREVITY_LENGTH

The maximum length for a single line string when trying to be brief

protected static final int MAX_BYTE_COUNT_BEFORE_TRUNCATION

The number of bytes to display when showing byte array

protected static final char NEW_LINE

New line delimiter

protected static final java.lang.String TRUNCATION_MARKER

How truncated values are shown

Constructor Summary

Modifier Constructor Description
protected GraphServiceException(String method, String url, List<String> requestHeaders, String requestBody, int responseCode, String responseMessage, List<String> responseHeaders, GraphErrorResponse error, boolean verbose)

Create a Graph service exception

Method Summary

Modifier and Type Method and Description
static GraphServiceException createFromResponse(IHttpRequest request, T serializable, ISerializer serializer, Response response, ILogger logger)

Creates a Graph service exception from a given failed HTTP request

static GraphServiceException createFromResponse(String url, String method, List<String> requestHeaders, String requestBody, Map<String,String> headers, String responseMessage, int responseCode, GraphErrorResponse error, boolean isVerbose)

Creates a Graph service exception.

GraphErrorResponse getError()

Gets the error returned by the service

java.lang.String getMessage()
java.lang.String getMessage(boolean verbose)

Gets the message for this exception

java.lang.String getMethod()

Gets the HTTP method of the request

java.util.List<java.lang.String> getRequestHeaders()

Gets the request headers

int getResponseCode()

Gets the HTTP status code

java.util.List<java.lang.String> getResponseHeaders()

Gets the response headers

protected static java.util.Map<java.lang.String,java.lang.String> getResponseHeadersAsMapStringString(Response response)

Gets the response headers from OkHttp Response

java.lang.String getResponseMessage()

Gets the The HTTP response message

GraphError getServiceError()

Gets the error message from the Graph service object

java.lang.String getUrl()

Gets the URL of the request

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Methods inherited from java.lang.Throwable

java.lang.Throwable.addSuppressed java.lang.Throwable.fillInStackTrace java.lang.Throwable.getCause java.lang.Throwable.getLocalizedMessage java.lang.Throwable.getMessage java.lang.Throwable.getStackTrace java.lang.Throwable.getSuppressed java.lang.Throwable.initCause java.lang.Throwable.printStackTrace java.lang.Throwable.printStackTrace java.lang.Throwable.printStackTrace java.lang.Throwable.setStackTrace java.lang.Throwable.toString

Field Details

INTERNAL_SERVER_ERROR

public static final int INTERNAL_SERVER_ERROR

The internal server error threshold defined by the HTTP protocol

MAX_BREVITY_LENGTH

protected static final int MAX_BREVITY_LENGTH

The maximum length for a single line string when trying to be brief

MAX_BYTE_COUNT_BEFORE_TRUNCATION

protected static final int MAX_BYTE_COUNT_BEFORE_TRUNCATION

The number of bytes to display when showing byte array

NEW_LINE

protected static final char NEW_LINE

New line delimiter

TRUNCATION_MARKER

protected static final String TRUNCATION_MARKER

How truncated values are shown

Constructor Details

GraphServiceException

protected GraphServiceException(String method, String url, List requestHeaders, String requestBody, int responseCode, String responseMessage, List responseHeaders, GraphErrorResponse error, boolean verbose)

Create a Graph service exception

Parameters:

method - the method that caused the exception
url - the URL
requestHeaders - the request headers
requestBody - the request body
responseCode - the response code
responseMessage - the response message
responseHeaders - the response headers
error - the error response if available
verbose - the error response log level

Method Details

createFromResponse

public static GraphServiceException createFromResponse(IHttpRequest request, T serializable, ISerializer serializer, Response response, ILogger logger)

Creates a Graph service exception from a given failed HTTP request

Parameters:

request - the request that resulted in this failure
serializable - the serialized object that was sent with this request
serializer - the serializer to re-create the option in its over the wire state
response - the response being used to extract information from
logger - the logger to log exception information to

Returns:

the new GraphServiceException instance

Throws:

java.io.IOException - an exception occurs if there were any problems processing the connection

createFromResponse

public static GraphServiceException createFromResponse(String url, String method, List requestHeaders, String requestBody, Map headers, String responseMessage, int responseCode, GraphErrorResponse error, boolean isVerbose)

Creates a Graph service exception.

Parameters:

url - url of the original request
method - http method of the original request
requestHeaders - headers of the original request
requestBody - body of the original request
headers - response headers
responseMessage - reponse status message
responseCode - response status code
error - graph error response object
isVerbose - whether to display a verbose message or not

Returns:

the Exception to be thrown

getError

public GraphErrorResponse getError()

Gets the error returned by the service

Returns:

the error returned by the service

getMessage

public String getMessage()

Overrides:

GraphServiceException.getMessage()

getMessage

public String getMessage(boolean verbose)

Gets the message for this exception

Parameters:

verbose - if the message should be brief or more verbose

Returns:

the message.

getMethod

public String getMethod()

Gets the HTTP method of the request

Returns:

the HTTP method of the request

getRequestHeaders

public List getRequestHeaders()

Gets the request headers

Returns:

the request headers

getResponseCode

public int getResponseCode()

Gets the HTTP status code

Returns:

The HTTP status response code

getResponseHeaders

public List getResponseHeaders()

Gets the response headers

Returns:

the response headers

getResponseHeadersAsMapStringString

protected static Map getResponseHeadersAsMapStringString(Response response)

Gets the response headers from OkHttp Response

Parameters:

response - the OkHttp response

Returns:

the set of headers names and value

getResponseMessage

public String getResponseMessage()

Gets the The HTTP response message

Returns:

The HTTP response message

getServiceError

public GraphError getServiceError()

Gets the error message from the Graph service object

Returns:

the error message

getUrl

public String getUrl()

Gets the URL of the request

Returns:

the URL of the request

Applies to