Package com.microsoft.graph.http
Class GraphServiceException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.microsoft.graph.core.ClientException
com.microsoft.graph.http.GraphServiceException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
GraphFatalServiceException
An exception from the Graph service
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe internal server error threshold defined by the HTTP protocolprotected static final intThe maximum length for a single line string when trying to be briefprotected static final intThe number of bytes to display when showing byte arrayprotected static final charNew line delimiterprotected static final StringHow truncated values are shown -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGraphServiceException(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 TypeMethodDescriptionstatic <T> GraphServiceExceptioncreateFromResponse(IHttpRequest request, T serializable, ISerializer serializer, okhttp3.Response response, ILogger logger) Creates a Graph service exception from a given failed HTTP requeststatic GraphServiceExceptioncreateFromResponse(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.getError()Gets the error returned by the servicegetMessage(boolean verbose) Gets the message for this exceptionGets the HTTP method of the requestGets the request headersintGets the HTTP status codeGets the response headersgetResponseHeadersAsMapStringString(okhttp3.Response response) Gets the response headers from OkHttp ResponseGets the The HTTP response messageGets the error message from the Graph service objectgetUrl()Gets the URL of the requestMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
NEW_LINE
protected static final char NEW_LINENew line delimiter- See Also:
-
TRUNCATION_MARKER
How truncated values are shown- See Also:
-
MAX_BREVITY_LENGTH
protected static final int MAX_BREVITY_LENGTHThe maximum length for a single line string when trying to be brief- See Also:
-
MAX_BYTE_COUNT_BEFORE_TRUNCATION
protected static final int MAX_BYTE_COUNT_BEFORE_TRUNCATIONThe number of bytes to display when showing byte array- See Also:
-
INTERNAL_SERVER_ERROR
public static final int INTERNAL_SERVER_ERRORThe internal server error threshold defined by the HTTP protocol- See Also:
-
-
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 exceptionurl- the URLrequestHeaders- the request headersrequestBody- the request bodyresponseCode- the response coderesponseMessage- the response messageresponseHeaders- the response headerserror- the error response if availableverbose- the error response log level
-
-
Method Details
-
getResponseMessage
Gets the The HTTP response message- Returns:
- The HTTP response message
-
getMessage
- Overrides:
getMessagein classThrowable
-
getResponseCode
public int getResponseCode()Gets the HTTP status code- Returns:
- The HTTP status response code
-
getResponseHeaders
Gets the response headers- Returns:
- the response headers
-
getError
Gets the error returned by the service- Returns:
- the error returned by the service
-
getMethod
Gets the HTTP method of the request- Returns:
- the HTTP method of the request
-
getUrl
Gets the URL of the request- Returns:
- the URL of the request
-
getRequestHeaders
Gets the request headers- Returns:
- the request headers
-
getMessage
Gets the message for this exception- Parameters:
verbose- if the message should be brief or more verbose- Returns:
- the message.
-
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 failureserializable- the serialized object that was sent with this requestserializer- the serializer to re-create the option in its over the wire stateresponse- the response being used to extract information fromlogger- 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 requestmethod- http method of the original requestrequestHeaders- headers of the original requestrequestBody- body of the original requestheaders- response headersresponseMessage- reponse status messageresponseCode- response status codeerror- graph error response objectisVerbose- 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
-