Handling Exceptions
  • 09 Oct 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

Handling Exceptions

  • Dark
    Light
  • PDF

Article summary

Java SDK.NET SDK

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;
}


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, our interactive help assistant