# Java Exception Handling

In case of errors, LicenseSpring SDK will throw an exception. SDK-specific exceptions always derive from the `LicenseSpringException` class. We have tried to wrap every exception under `LicenseSpringException`; please open a support ticket if you find a method where this is not the case.

LicenseSpringException - All SDK Exceptions inherit from this exception.

* `LicenseSpringServerException` - Any License server error is wrapped in this exception. The response is wrapped in the `ErrorResponse` class.
  * Server Error - If LicenseSpring API returns HTTP status in range \[500, 599] then this exception will be thrown. See [**Errors and Response Codes**](broken://pages/b220fcc07d1afe8808b8be19b90e4cbebd668f1d) for detailed messages.
  * `ServerValidationException` - Any License Client error is wrapped in this exception. If LicenseSpring API returns HTTP status in range \[400, 499] then this exception will be thrown. See [**Errors and Response Codes**](broken://pages/b220fcc07d1afe8808b8be19b90e4cbebd668f1d) for detailed messages.
* `ClientValidationException` - Thrown when some validation rule is broken. Example: if you do not provide an API key or another required field then this exception will be thrown.
  * `LicenseExpiredException` - Thrown if license has expired.
  * `ConsumptionException` - Thrown if license has expired.
  * `ConfigurationException` - Thrown when configuration files are misconfigured.
* `InfrastructureException` - The SDKs wrap IO and similar exceptions under this class.
  * `ConnectionException` - Thrown when the client fails to connect to the server. Examples: host unreachable, connection timeout, or connection refused. In all these scenarios the client won't receive any response from the server.
  * `CloudCheckException` - These exceptions are thrown only when one of the `NODE_LOCKING` Hardware ID Strategies is present. They all relate to failing to obtain metadata information about the instance.
    * `MetadataServiceBlockedException` - Thrown if connection is refused while trying to retrieve Cloud platform instance ID.
    * `NotCloudPlatformException` - Thrown if trying to retrieve Instance ID of a VM running on a Cloud Platform from a physical computer.
    * `WrongPlatformException` - Thrown if trying to retrieve Instance ID of a VM running on AWS from Azure Cloud platform or vice-versa.

POPRAVI SLIKU

![](https://api.archbee.com/api/optimize/IJdHyjBlO9LOXOrDnWJTx/anagD-MvzO7mXDMzmc8NB_image.png)

{% code title="ErrorResponse.java" %}

```java
@Value
public class ErrorResponse {
    private int status;
    private String code;
    private String message;
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.licensespring.com/sdks/java-sdk/java-exception-handling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
