Search code examples
htmlhtml5-appcache

How to get error message on a HTML5 Application Cache Error event?


During the caching of my offline webapp I receive a totally valid error which is displayed in the browser console like this:

Application Cache Error event: Manifest changed during update, scheduling retry

I can add a Listener to be informed that an error has occured.

window.applicationCache.addEventListener('error', function(e){
  //handle error here
}, false);

How can I get the error detail, in this case "Manifest changed during update, scheduling retry"?


Solution

  • You must use window.onerror. The callback can have three parameters:

    Error message (string)
    Url where error was raised (string)
    Line number where error was raised (number)
    

    check this for more information: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers.onerror