Skip to content

Exception handling

sea edited this page May 23, 2023 · 3 revisions

ResultException

"ResultException"s are the common, generic base type for all exceptions thrown by the wsclient. If you don´t require a more detailed error handling, it is sufficient to handle all "ResultException"s in a common catch:

try {   
   let session: RestSession<RestDocument> = await SessionFactory.createInstance(sessionContext, authProvider);
   ...
} catch (error) {
   let resultException: ResultException = error;
   let msg: string = resultException.getMessage();
   let clientError: WsclientError = resultException.getClientError();
   let errorCode: number = resultException.getErrorCode();
   let cause: Error | undefined = resultException.getCause();
}

ClientResultException

A "ClientResultException" is a subtype of a ResultException that indicates some fail state of your wsclient application. The error codes contained in a "ClientResultException" must not be confused with the webPDF server error codes and are strictly limited to describing issues in the wsclient library.

You can find those error codes described here.

ServerResultException

A "ServerResultException" describes a fail state of the webPDF server itself. The server encountered some error, while executing your request. You can find those error codes described here.

AuthResultException

wsclient 9.0.0 introduced the ability to use custom TokenProviders for OAuth2 authorization. You have to provide some implementation of such an OAuth2Provider and in doing so, you may encounter and rethrow any number of custom Exceptions.
A "AuthResultException" is a subtype of a ResultException that wraps those exceptions and stores the actual exception as it´s cause.

Clone this wiki locally