---
title: "Handling SDK Exceptions"
slug: "handling-sdk-exceptions"
updated: 2024-10-09T10:32:35Z
published: 2024-10-09T10:32:35Z
canonical: "docs.onespan.com/handling-sdk-exceptions"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Handling SDK Exceptions

When the SDK encounters a problem, it throws one of the following exception types:

- `EslException`: This is a general exception. It includes a character string that indicates what failed.
- `EslServerException`: This is a subclass of `EslException`. An `EslServerException` is thrown when the server returns unexpected code from a request. The `EslServerException` also contains the exact server response from the underlying API request.

The following code samples illustrate: (1) how to differentiate between those two exception types; (2) how to gain access to the underlying server response if an `EslServerException` is thrown:

```java
try {
    PackageId packageId = eslClient.createPackageOneStep( superDuperPackage );
} catch (EslServerException serverException) {
    System.out.println( "The server could not complete the request." );
    System.out.println( serverException.getMessage() );
    System.out.println( "HTTP code: " + serverException.getServerError().getCode());
    System.out.println( "Server message: " + serverException.getServerError().getMessage());
} catch (EslException exception) {
    System.out.println( exception.getMessage() );
    System.out.println( exception.getCause().getMessage() );
}
```

```csharp
try {
    PackageId packageId = eslClient.CreatePackageOneStep( superDuperPackage );
} catch (EslServerException serverException) {
    Console.Out.WriteLine( "The server could not complete the request." );
    Console.Out.WriteLine( serverException.Message );
    Console.Out.WriteLine( "HTTP code: " + serverException.ServerError.Code);
    Console.Out.WriteLine( "Server message: " + serverException.ServerError.Message);
} catch (EslException exception) {
    Console.Out.WriteLine( exception.Message );
    Console.Out.WriteLine( exception.InnerException.Message );
}
```
