Skip to content

Commit

Permalink
Check online status first
Browse files Browse the repository at this point in the history
Closes #3037
  • Loading branch information
fregante committed May 12, 2022
1 parent 5cf0203 commit 7257e52
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/utils/enrichAxiosErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ async function enrichBusinessRequestError(error: unknown): Promise<never> {

console.trace("enrichBusinessRequestError", { error });

if (!navigator.onLine) {
throw new ClientNetworkError(NO_INTERNET_MESSAGE, { cause: error });
}

// This should have already been called before attempting the request because Axios does not actually catch invalid URLs
const url = assertHttpsUrl(error.config.url, error.config.baseURL);

Expand All @@ -71,10 +75,6 @@ async function enrichBusinessRequestError(error: unknown): Promise<never> {
throw new RemoteServiceError(getErrorMessage(error), { cause: error });
}

if (!navigator.onLine) {
throw new ClientNetworkError(NO_INTERNET_MESSAGE, { cause: error });
}

const hasPermissions = await browser.permissions.contains({
origins: [url.href],
});
Expand Down

0 comments on commit 7257e52

Please sign in to comment.