Changed the error handling location

This commit is contained in:
Omar Ajoue 2021-09-28 15:20:01 +02:00
parent b873eec2ad
commit 694ec64330
2 changed files with 3 additions and 6 deletions

View file

@ -106,11 +106,7 @@ export interface IPollFunctions extends IPollFunctionsBase {
}
export interface IResponseError extends Error {
status?: number; // this is how the request library returns
response?: {
// this is how Axios returns
status: number;
};
statusCode?: number;
}
export interface ITriggerFunctions extends ITriggerFunctionsBase {

View file

@ -415,6 +415,7 @@ async function proxyRequestToAxios(
}
})
.catch((error) => {
error.statusCode = error.response.status;
reject(error);
});
});
@ -673,7 +674,7 @@ export async function requestOAuth2(
? 401
: oAuth2Options?.tokenExpiredStatusCode;
if (error.response?.status === statusCodeReturned || error.status === statusCodeReturned) {
if (error.statusCode === statusCodeReturned) {
// Token is probably not valid anymore. So try refresh it.
const tokenRefreshOptions: IDataObject = {};