Skip to content

Commit

Permalink
Add error notification for failed wallpaper downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucki committed Apr 12, 2024
1 parent 20135f2 commit 6b97550
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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 failing to download the next wallpaper.
*
* @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('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

0 comments on commit 6b97550

Please sign in to comment.