- 09 Oct 2024
- 1 Minute to read
- DarkLight
- PDF
Handling Exceptions
- Updated on 09 Oct 2024
- 1 Minute to read
- DarkLight
- PDF
Java SDK
To download the full code sample see our Code Share site.
The following exception types exist in OneSpan Sign:
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 sample illustrates how to differentiate between these exception types and how to gain access to the underlying server response if an EslServerException is thrown:
try {
signer = signerBuilder.build();
} catch( EslException eslException ) {
System.out.println( eslException.getLocalizedMessage() );
return;
}
try {
eslClient.getPackageService().addSigner( new PackageId( "myPackageId" ), signer);
} catch( EslServerException eslServerException ) {
// The request was refused by the server for some reason...
System.out.println(eslServerException.getLocalizedMessage());
System.out.println(eslServerException.getServerError().getCode());
System.out.println(eslServerException.getServerError().getMessage());
System.out.println(eslServerException.getServerError().getTechnical());
return;
} catch( EslException eslException ) {
System.out.println( eslException.getLocalizedMessage() );
return;
}
.NET SDK
To download the full code sample see our Code Share site.
The following exception types exist in OneSpan Sign:
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 sample illustrates how to differentiate between these exception types and how to gain access to the underlying server response if an EslServerException is thrown:
try
{
signer = signerBuilder.Build();
}
catch (EslException eslException)
{
Console.Out.WriteLine(eslException.Message);
return;
}
try
{
eslClient.PackageService.AddSigner(new PackageId("myPackageId"),signer);
}
catch (EslServerException eslServerException)
{
Console.Out.WriteLine(eslServerException.Message);
Console.Out.WriteLine(eslServerException.ServerError.Code);
Console.Out.WriteLine(eslServerException.ServerError.Message);
Console.Out.WriteLine(eslServerException.ServerError.Technical);
}
catch (EslException eslException)
{
Console.Out.WriteLine(eslException.Message);
return;
}