Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit 8eb5fdf

Browse files
committed
feat: improve error handling with user notifications for network issues
1 parent 9f9cafc commit 8eb5fdf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default class CssSnippetStore extends Plugin {
2626
if (await isOnline()) {
2727
const response = await fetchWithTimeout(url);
2828
if (!response.ok) {
29-
throw new Error(`Network response was not ok: ${response.statusText}`);
29+
new Notice(`Network response was not ok: ${response.statusText}`);
30+
return;
3031
}
3132
/*
3233
if (!response.headers.get('content-type')?.includes('application/json')) {
@@ -182,7 +183,10 @@ class CssSnippetStoreModal extends Modal {
182183
try {
183184
if (await isOnline()) {
184185
const response = await fetchWithTimeout(url);
185-
if (!response.ok) throw new Error(`Network response was not ok: ${response.statusText}`);
186+
if (!response.ok) {
187+
new Notice(`Network response was not ok: ${response.statusText}`);
188+
return;
189+
}
186190
const code = await response.text();
187191
await this.install(snippet.id, code);
188192
this.updateSnippetCard(snippet);

0 commit comments

Comments
 (0)