# 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**](https://docs.licensespring.com/sdks/java-sdk/broken-reference) 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**](https://docs.licensespring.com/sdks/java-sdk/broken-reference) 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 %}
