Skip to content

Commit

Permalink
response field is optional on AxiosError, so we need to check if it e…
Browse files Browse the repository at this point in the history
…xists (#732)
  • Loading branch information
adrianmroz-allegro committed Apr 20, 2021
1 parent ef053d2 commit f2213ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/client/oauth/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ export const isOauthError = (error: Error): error is OauthError =>
error.hasOwnProperty("isOauthError");

export function mapOauthError(oauth: Oauth, error: AxiosError): Error {
if (!!oauth) {
if (!!oauth && !!error.response) {
const { response: { status } } = error;
if (status === 401) return new OauthAuthenticationError();
if (status === 403) return new OauthAuthorizationError();
if (status === 401) return new OauthAuthenticationError(error.message);
if (status === 403) return new OauthAuthorizationError(error.message);
}
return error;
}
Expand Down

0 comments on commit f2213ae

Please sign in to comment.