locked
Handle app crash problem

    Question

  • Although it's possible to check app crash information in windows store, I want to write a log and send error stack to my own server. But both file writing and WinJS.xhr seems to be promises that could't finish before app crashing. I've tried to handle this in WinJS.Application.onerror but it only worked when debugging with breakpoints.

    Is there any way to handle this? Thank you for your attention.

     
    Tuesday, February 25, 2014 3:54 AM

Answers

  • Hi Polaris,

    To handle the error by WinJS.Application.onerror is a correct choice, the problem is you do not have enough time to log them into file.

    Take a look at Kraig's blog: http://kraigbrockschmidt.com/blog/?p=334, should be able to know when the WinJS.Application.onerror fires, the app will not crash, but when the MSApp.terminateApp() method has been called, the app crash, so we still have time to log the file.

    I found an interesting blog: WinJSLog - A Logging and Reporting JavaScript Module For Windows 8 Store Apps , where you could manually handle the crash event by following code:

      Windows.Application.onerror = function (e) {
            showErrorPage();
            return true; // telling WinJS that the exception was handled, don't terminate
        }

    By this, I think you can have enough time to handle your own operation.

    However I did not test if the WinJS.Application.onerror will not work by release mode, but I could not find any documentation for such situation.

    Hope this helps.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, February 25, 2014 6:39 AM
    Moderator

All replies

  • Hi Polaris,

    To handle the error by WinJS.Application.onerror is a correct choice, the problem is you do not have enough time to log them into file.

    Take a look at Kraig's blog: http://kraigbrockschmidt.com/blog/?p=334, should be able to know when the WinJS.Application.onerror fires, the app will not crash, but when the MSApp.terminateApp() method has been called, the app crash, so we still have time to log the file.

    I found an interesting blog: WinJSLog - A Logging and Reporting JavaScript Module For Windows 8 Store Apps , where you could manually handle the crash event by following code:

      Windows.Application.onerror = function (e) {
            showErrorPage();
            return true; // telling WinJS that the exception was handled, don't terminate
        }

    By this, I think you can have enough time to handle your own operation.

    However I did not test if the WinJS.Application.onerror will not work by release mode, but I could not find any documentation for such situation.

    Hope this helps.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, February 25, 2014 6:39 AM
    Moderator
  • Thanks a lot. It's really helpful
    Wednesday, February 26, 2014 1:39 AM