NekR / offline-plugin

Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
MIT License
4.52k stars 295 forks source link

Advanced Error Handling #243

Open rriverak opened 7 years ago

rriverak commented 7 years ago

Hi, first many thanks for this great Project. We need to ensure that our application is always available offline. Always in the latest version.

For this purpose, we have build a loadingscreen to process this. However, there are some problems which we want to handle.

Here is a Sample from ServiceWorker:

DOMException: Quota exceeded.
Uncaught (in promise) DOMException: Quota exceeded.

Its possible to pass this exceptions and Errors to the onUpdateFailed event ? We want to give the user better error messages.

Of course, the error messages are not really cross browser but we'll take what we get :)

NekR commented 7 years ago

Hi, thank you. It's probably possible to do that, but how did you manage to exceed the quota? It's at least 50MB for worst scenario (no free space on the device).

NekR commented 7 years ago

or... is that AppCache error?

rriverak commented 7 years ago

Hi, it´s a ServiceWorker Error. We would like more details than "broken". It would help our support team solve problems.

Quota is just one example... I have provoked this in which I have filled my hard disk to 99%.

NekR commented 7 years ago

I see. That makes sense, but unfortunately it isn't very straightforward to get the error of fail. I'll think about it :-)

rriverak commented 7 years ago

I think the easiest way would be to implement onerror... This event is fired outside of the Serviceworker and catch all unhandled Exception.

https://developer.mozilla.org/de/docs/Web/API/ServiceWorkerContainer/onerror

NekR commented 7 years ago

@likebrain Probably. Need to test if it's actually useful. In a meantime, you can assign a listener to it yourself in your code and on onUpdateFailed use the last error from it.