1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

Merge pull request #283 from sasjs/error-handling

fix(error-handling): catching unhandled promise rejection
This commit is contained in:
Yury Shkoda
2021-03-09 17:15:10 +03:00
committed by GitHub

View File

@@ -93,6 +93,7 @@ export class RequestClient implements HttpClient {
.get<T>(url, requestConfig)
.then((response) => {
throwIfError(response)
return this.parseResponse<T>(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
}