Skip to content

Commit

Permalink
fix: ensure custom error codes take precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Jun 11, 2024
1 parent 8dcaf8d commit 5fe3843
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/hoppscotch-cli/src/utils/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ export const getResourceContents = async ({
statusCode: number;
}>;

const errReason = axiosErr.response?.data?.reason;

if (errReason) {
throw error({
code: errReason,
data: ["TOKEN_EXPIRED", "TOKEN_INVALID"].includes(errReason)
? accessToken
: pathOrId,
});
}

if (axiosErr.code === "ECONNREFUSED") {
throw error({ code: "SERVER_CONNECTION_REFUSED", data: serverUrl });
}
Expand All @@ -210,17 +221,6 @@ export const getResourceContents = async ({
) {
throw error({ code: "INVALID_SERVER_URL", data: serverUrl });
}

const errReason = axiosErr.response?.data?.reason;

if (errReason) {
throw error({
code: errReason,
data: ["TOKEN_EXPIRED", "TOKEN_INVALID"].includes(errReason)
? accessToken
: pathOrId,
});
}
}
}

Expand Down

0 comments on commit 5fe3843

Please sign in to comment.