Skip to content

Commit 2ff2022

Browse files
committed
fix: if there is issue with internet/network, show it as a dedicated message
1 parent e75d10b commit 2ff2022

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adminforth/spa/src/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ export async function callApi({path, method, body=undefined}: {
3131
}
3232
return await r.json();
3333
} catch(e) {
34+
// if it is internal error, say to user
35+
if (e instanceof TypeError && e.message === 'Failed to fetch') {
36+
// this is a network error
37+
adminforth.alert({variant:'danger', message: window.i18n?.global?.t('Network error, please check your Internet connection and try again'),})
38+
return null;
39+
}
40+
3441
adminforth.alert({variant:'danger', message: window.i18n?.global?.t('Something went wrong, please try again later'),})
3542
console.error(`error in callApi ${path}`, e);
3643
}

0 commit comments

Comments
 (0)