mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-06 04:00:05 +00:00
fix(error-handling): catching unhandled promise rejection
This commit is contained in:
@@ -93,6 +93,7 @@ export class RequestClient implements HttpClient {
|
|||||||
.get<T>(url, requestConfig)
|
.get<T>(url, requestConfig)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
throwIfError(response)
|
throwIfError(response)
|
||||||
|
|
||||||
return this.parseResponse<T>(response)
|
return this.parseResponse<T>(response)
|
||||||
})
|
})
|
||||||
.catch(async (e) => {
|
.catch(async (e) => {
|
||||||
@@ -106,7 +107,6 @@ export class RequestClient implements HttpClient {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
).catch((err) => {
|
).catch((err) => {
|
||||||
console.log(`[err]`, err)
|
|
||||||
throw prefixMessage(err, 'Error while handling error. ')
|
throw prefixMessage(err, 'Error while handling error. ')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -388,6 +388,8 @@ export class RequestClient implements HttpClient {
|
|||||||
throw new NotFoundError(response.config.url!)
|
throw new NotFoundError(response.config.url!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[e]`, e)
|
||||||
|
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +458,10 @@ const throwIfError = (response: AxiosResponse) => {
|
|||||||
throw new AuthorizeError(response.data.message, authorizeRequestUrl)
|
throw new AuthorizeError(response.data.message, authorizeRequestUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[response]`, response)
|
||||||
|
|
||||||
const error = parseError(response.data as string)
|
const error = parseError(response.data as string)
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user