sindresorhus / Plash

💦 Make any website your Mac desktop wallpaper
https://sindresorhus.com/plash
MIT License
3.53k stars 130 forks source link

Improve error handling #11

Open hu0p opened 4 years ago

hu0p commented 4 years ago

Hi Sindre! This is awesome, and I've wanted to do something like this for a long time. Thanks for all your hard work!

Something I noticed when trying out the Unsplash random puppy API example is that it seems to occasionally return dead URLs. When that happens, this error is thrown:

Screen Shot 2020-01-09 at 11 27 01 AM

This also happens if any server Plash is periodically hitting suddenly goes down or a URL to somewhere that is obviously down is entered in the config. I think the latter may have also just led to a crash for me.

Would it be possible to do an initial check to see if a server is up when it's entered in the config and in the event that it becomes unavailable notify the user of an error via the menu bar icon? Meanwhile, Plash could keep testing for valid responses in the background while maintaining the current valid image.

I'd love to help out with this, but I'm afraid I have very minimal knowledge of Swift. I write JS for a living. 😅

sindresorhus commented 4 years ago

I've implemented part of this in https://github.com/sindresorhus/Plash/commit/be2f3825eeeaea4559e97d8954ee29ad3d835b86.

Don't show interactive error message when not in browsing mode. Instead, make the menu bar icon red and show the error in the menu bar icon tooltip and menu.

We still have to do:

Meanwhile, Plash could keep testing for valid responses in the background while maintaining the current valid image.

For this, we'll need to maintain two web view and only switch to the new web view on success. This is also needed for #9.