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.

Gestion des exceptions

Prev Next

Java SDK  .NET SDK

Java SDK

Pour télécharger l’exemple de code complet, consultez notre site Code Share .

Les types d’exception suivants existent dans OneSpan Sign :

  • EslException : il s’agit d’une exception générale. Il comprend une chaîne de caractères qui indique ce qui a échoué.

  • EslServerException : il s’agit d’une sous-classe de EslException. Une exception EslServerException est levée lorsque le serveur renvoie du code inattendu à partir d’une demande. L’EslServerException contient également la réponse exacte du serveur à partir de la demande d’API sous-jacente.

L’exemple de code suivant illustre comment différencier ces types d’exceptions et comment accéder à la réponse du serveur sous-jacent si une EslServerException est levée :

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

Kit de développement logiciel (SDK) .NET

Pour télécharger l’exemple de code complet, consultez notre site Code Share .

Les types d’exception suivants existent dans OneSpan Sign :

  • EslException : il s’agit d’une exception générale. Il comprend une chaîne de caractères qui indique ce qui a échoué.

  • EslServerException : il s’agit d’une sous-classe de EslException. Une exception EslServerException est levée lorsque le serveur renvoie du code inattendu à partir d’une demande. L’EslServerException contient également la réponse exacte du serveur à partir de la demande d’API sous-jacente.

L’exemple de code suivant illustre comment différencier ces types d’exceptions et comment accéder à la réponse du serveur sous-jacent si une EslServerException est levée :

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