Class GraphServiceException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
GraphFatalServiceException

public class GraphServiceException extends ClientException
An exception from the Graph service
See Also:
Serialized Form
  • Field Details

    • NEW_LINE

      protected static final char NEW_LINE
      New line delimiter
      See Also:
      Constant Field Values
    • TRUNCATION_MARKER

      protected static final String TRUNCATION_MARKER
      How truncated values are shown
      See Also:
      Constant Field Values
    • MAX_BREVITY_LENGTH

      protected static final int MAX_BREVITY_LENGTH
      The maximum length for a single line string when trying to be brief
      See Also:
      Constant Field Values
    • MAX_BYTE_COUNT_BEFORE_TRUNCATION

      protected static final int MAX_BYTE_COUNT_BEFORE_TRUNCATION
      The number of bytes to display when showing byte array
      See Also:
      Constant Field Values
    • INTERNAL_SERVER_ERROR

      public static final int INTERNAL_SERVER_ERROR
      The internal server error threshold defined by the HTTP protocol
      See Also:
      Constant Field Values
  • Constructor Details

    • GraphServiceException

      protected GraphServiceException(@Nonnull String method, @Nonnull String url, @Nonnull List<String> requestHeaders, @Nullable String requestBody, int responseCode, @Nonnull String responseMessage, @Nonnull List<String> responseHeaders, @Nullable 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

    • getResponseMessage

      @Nullable public String getResponseMessage()
      Gets the The HTTP response message
      Returns:
      The HTTP response message
    • getMessage

      @Nullable public String getMessage()
      Overrides:
      getMessage in class Throwable
    • getResponseCode

      public int getResponseCode()
      Gets the HTTP status code
      Returns:
      The HTTP status response code
    • getResponseHeaders

      @Nonnull public List<String> getResponseHeaders()
      Gets the response headers
      Returns:
      the response headers
    • getError

      @Nullable public GraphErrorResponse getError()
      Gets the error returned by the service
      Returns:
      the error returned by the service
    • getMethod

      @Nonnull public String getMethod()
      Gets the HTTP method of the request
      Returns:
      the HTTP method of the request
    • getUrl

      @Nonnull public String getUrl()
      Gets the URL of the request
      Returns:
      the URL of the request
    • getRequestHeaders

      @Nonnull public List<String> getRequestHeaders()
      Gets the request headers
      Returns:
      the request headers
    • getMessage

      @Nullable 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.
    • getServiceError

      @Nullable public GraphError getServiceError()
      Gets the error message from the Graph service object
      Returns:
      the error message
    • createFromResponse

      @Nonnull public static <T> GraphServiceException createFromResponse(@Nonnull IHttpRequest request, @Nullable T serializable, @Nonnull ISerializer serializer, @Nonnull okhttp3.Response response, @Nonnull ILogger logger) throws IOException
      Creates a Graph service exception from a given failed HTTP request
      Type Parameters:
      T - the type of the serializable object
      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:
      IOException - an exception occurs if there were any problems processing the connection
    • createFromResponse

      @Nonnull public static GraphServiceException createFromResponse(@Nullable String url, @Nullable String method, @Nonnull List<String> requestHeaders, @Nullable String requestBody, @Nonnull Map<String,​String> headers, @Nonnull String responseMessage, int responseCode, @Nonnull 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
    • getResponseHeadersAsMapStringString

      @Nonnull protected static Map<String,​String> getResponseHeadersAsMapStringString(@Nonnull okhttp3.Response response)
      Gets the response headers from OkHttp Response
      Parameters:
      response - the OkHttp response
      Returns:
      the set of headers names and value