locked
Recommended way to stop JS exceptions from crashing the App

    Question

  • Is there a way to prevent unhandled JS exceptions from crashing the App?

    We've tried adding a window.onerror listener, but that doesn't seem to be notified (which is not surprising, given the constrained environment for Win8 JS apps), so was wondering if there's something in the WinJS or Windows API which we should be using instead  to capture/handle any errors which would bubble up to window.onerror in normal browser environments.


    • Edited by Satyen Desai Thursday, September 27, 2012 1:57 AM
    Thursday, September 27, 2012 1:56 AM

Answers

  • Actually, nm. window.onerror works fine...

    window.onerror = function(e) {
        console.log("Uncaught exception: " + e);
        return true;
    }
    Thursday, September 27, 2012 7:18 AM

All replies

  • To follow up on Satyen's comments - we've also tried WinJS.Application.onerror. It seems this wasn't getting fired either. 
    Thursday, September 27, 2012 2:55 AM
  • Actually, nm. window.onerror works fine...

    window.onerror = function(e) {
        console.log("Uncaught exception: " + e);
        return true;
    }
    Thursday, September 27, 2012 7:18 AM