Skip to content

MindSphere SDK V2 for Java - Exception Handling

Info

Exception handling in the MindSphere SDK V2 for Java is identical to the one of V1.

Understanding how and when the MindSphere SDK V2 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

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 occurred error

Structure of MindsphereException

Name Description Type
errorStatusCode Error code (if returned by API) String
errorMessage Error message String
httpStatus HTTP status HttpStatus
logref Logger reference (if returned by API) String
cause Cause of the exception (if available) Throwable

Subclasses of MindsphereException

MindsphereServiceException is a subclass of MindsphereException. It is thrown when an error occurs at the API endpoint. For example, if the user tries to call an API with invalid values for mandatory parameters.

MindsphereClientException is a subclass of MindsphereException. It is thrown when an error occurs due to missing parameter values in a request. For example, if the user tries to call an API with NULL values for mandatory parameters.

MindsphereClientConfigurationException is a subclass of MindsphereClientException. It is thrown when an error occurs due to incorrect configuration parameters. For example, if a user sets an incorrect value for the proxy host or proxy port.

MindsphereForbiddenAccessException is a subclass of MindsphereClientException. It is thrown when no valid token can be retrieved with the provided credentials.

Any questions left?

Ask the community


Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.