From 15e1acaf4fb9fa785e65a8ed114a902ad7548b3a Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Tue, 9 Mar 2021 17:11:29 +0300 Subject: [PATCH] fix(error-handling): catching unhandled promise rejection --- src/request/RequestClient.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/request/RequestClient.ts b/src/request/RequestClient.ts index d11a76d..4c61eef 100644 --- a/src/request/RequestClient.ts +++ b/src/request/RequestClient.ts @@ -93,6 +93,7 @@ export class RequestClient implements HttpClient { .get(url, requestConfig) .then((response) => { throwIfError(response) + return this.parseResponse(response) }) .catch(async (e) => { @@ -106,7 +107,6 @@ export class RequestClient implements HttpClient { } ) ).catch((err) => { - console.log(`[err]`, err) throw prefixMessage(err, 'Error while handling error. ') }) }) @@ -388,6 +388,8 @@ export class RequestClient implements HttpClient { throw new NotFoundError(response.config.url!) } + console.log(`[e]`, e) + throw e } @@ -456,7 +458,10 @@ const throwIfError = (response: AxiosResponse) => { throw new AuthorizeError(response.data.message, authorizeRequestUrl) } + console.log(`[response]`, response) + const error = parseError(response.data as string) + if (error) { throw error }