From a977f59675e488e94e04374e599a8fc8ba867680 Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Tue, 9 Mar 2021 09:35:01 +0300 Subject: [PATCH] fix(error-handling): added catch block to poll job state --- src/SASViyaApiClient.ts | 8 +++++++- src/request/RequestClient.ts | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SASViyaApiClient.ts b/src/SASViyaApiClient.ts index 9dd85cf..1b5e497 100644 --- a/src/SASViyaApiClient.ts +++ b/src/SASViyaApiClient.ts @@ -977,7 +977,13 @@ export class SASViyaApiClient { postJobRequestBody, accessToken ) - const jobStatus = await this.pollJobState(postedJob, etag, accessToken) + const jobStatus = await this.pollJobState( + postedJob, + etag, + accessToken + ).catch((err) => { + throw prefixMessage(err, 'Error while polling job status. ') + }) const { result: currentJob } = await this.requestClient.get( `${this.serverUrl}/jobExecution/jobs/${postedJob.id}`, accessToken diff --git a/src/request/RequestClient.ts b/src/request/RequestClient.ts index 1d36fca..35adf7d 100644 --- a/src/request/RequestClient.ts +++ b/src/request/RequestClient.ts @@ -97,7 +97,9 @@ export class RequestClient implements HttpClient { }) .catch(async (e) => { return await this.handleError(e, () => - this.get(url, accessToken, contentType, overrideHeaders) + this.get(url, accessToken, contentType, overrideHeaders).catch((err) => { + throw prefixMessage(err, 'Error while executing handle error callback. ') + }) ).catch((err) => { throw prefixMessage(err, 'Error while handling error. ') })