Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error notification for failed wallpaper downloads #200

Merged
merged 2 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ class Notification {
const message = `A new wallpaper was set!\n${infoString}`;
notify('New Wallpaper', message);
}

/**
* Show an error notification for failed wallpaper downloads.
*
* @param {unknown} error The error that was thrown when fetching a new wallpaper
*/
static fetchWallpaperFailed(error: unknown): void {
let errorMessage = String(error);

if (error instanceof Error)
errorMessage = error.message;

notify('RandomWallpaperGnome3: Wallpaper Download Failed!', errorMessage);
}
}

export {Notification};
2 changes: 2 additions & 0 deletions src/wallpaperController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ class WallpaperController {
Notification.newWallpaper(newImageEntries.reverse());
} catch (error) {
Logger.error(error, this);
if (this._settings.getBoolean('show-notifications'))
Notification.fetchWallpaperFailed(error);
} finally {
this._stopLoadingHooks.forEach(element => element());
}
Expand Down
Loading