MindSphere SDK for Java - Exception Handling¶
Understanding how and when the MindSphere SDK for Java throws exceptions is important to build high-quality applications using the SDK. The following sections describe the different scenarios in which exceptions are thrown by the SDK and how to handle them appropriately.
MindSphereException is the most common exception that you'll experience when using the MindSphere SDK for Java. This exception represents an error response from a MindSphere service.
MindSphereException provides you with information such as:
- Returned HTTP status
- Returned HTTP status Code
- Detailed error message from the service
- Reference to the error occurred
Structure of MindSphereException¶
|errorStatusCode||Error code (if returned by API)||String|
|logref||Logger reference (if returned by API)||String|
|cause||Cause of the exception (if any)||Throwable|
Subclasses of MindSphereException¶
MindSphereClientException is a subclass of MindSphereException. It is thrown when an error occurs due to user's fault (a request with missing values). For example, if user tries to call an API with null values for mandatory parameters then MindSphereClientException is thrown to indicate that required parameters are missing.
MindSphereServiceException is a subclass of MindSphereException. It is thrown when an error occurs at the API endpoint. For example, if user tries to call an API with invalid values for mandatory parameters. A MindSphereServiceException is thrown only when an error is encountered at the API endpoint.
MindSphereClientConfigurationException is a subclass of MindSphereClientException. It is thrown when incorrect configuration parameters are set. For example, if a developer uses an incorrect value for the proxy, MindSphereClientConfigurationException is thrown to indicate that incorrect proxy host or proxy port.
Any questions left?
Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.