Package com.independentsoft.graph
Class GraphException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.independentsoft.graph.GraphException
- All Implemented Interfaces:
Serializable
Exception thrown when Microsoft Graph API requests fail.
This exception captures detailed error information from the Microsoft Graph API, including error codes, messages, request IDs, and timestamps. It parses both standard Graph API error responses and OAuth authentication error responses.
The exception provides access to:
- Error code - The Graph API error code (e.g., "InvalidAuthenticationToken")
- Error message - Human-readable description of the error
- Request ID - Unique identifier for troubleshooting with Microsoft support
- Date/Timestamp - When the error occurred
- Error details - Additional error information if available
- Request URI/Body - The request that caused the error for debugging
- Since:
- 1.0
- See Also:
- Microsoft Graph error responses, Serialized Form
-
Constructor Summary
ConstructorsConstructorDescriptionGraphException(String code, String message, InputStream inputStream, String requestUri, String requestBody)Constructs a GraphException by parsing the error response from Microsoft Graph API.GraphException(String message, Throwable cause, String requestUri, String requestBody)Constructs a GraphException with a message and underlying cause. -
Method Summary
Modifier and TypeMethodDescriptiongetCode()Gets the error code from the Microsoft Graph API response.Gets the correlation ID for OAuth authentication errors.getDate()Gets the timestamp when the error occurred.Gets additional error details if available.Gets the error URI with additional information about the error.Gets the detailed error message.Gets the unique request identifier for troubleshooting.Gets the trace ID for OAuth authentication errors.toString()Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
GraphException
Constructs a GraphException with a message and underlying cause.- Parameters:
message- The error messagecause- The underlying exception that caused this errorrequestUri- The URI of the request that failedrequestBody- The body of the request that failed
-
GraphException
public GraphException(String code, String message, InputStream inputStream, String requestUri, String requestBody)Constructs a GraphException by parsing the error response from Microsoft Graph API.This constructor parses the JSON error response to extract detailed error information including error code, message, request ID, timestamp, and any additional error details.
- Parameters:
code- The HTTP status code or error codemessage- The initial error messageinputStream- The response stream containing the error details in JSON formatrequestUri- The URI of the request that failedrequestBody- The body of the request that failed
-
-
Method Details
-
toString
-
getCode
Gets the error code from the Microsoft Graph API response.- Returns:
- The error code (e.g., "InvalidAuthenticationToken", "ResourceNotFound")
-
getMessage
Gets the detailed error message.- Overrides:
getMessagein classThrowable- Returns:
- The human-readable error message
-
getRequestId
Gets the unique request identifier for troubleshooting.This ID can be provided to Microsoft support to help diagnose issues.
- Returns:
- The request ID from the Graph API response
-
getDate
Gets the timestamp when the error occurred.- Returns:
- The date and time of the error
-
getDetails
Gets additional error details if available.- Returns:
- A list of error detail objects containing additional information
-
getTraceId
Gets the trace ID for OAuth authentication errors.- Returns:
- The trace ID from OAuth error responses
-
getCorrelationId
Gets the correlation ID for OAuth authentication errors.- Returns:
- The correlation ID from OAuth error responses
-
getErrorUri
Gets the error URI with additional information about the error.- Returns:
- A URI pointing to error documentation
-
getRequestUri
-
getRequestBody
-