I want to navigate to the home page of my app and display an error using a FlyOut when unhandled exceptions in Windows Metro occurs using WinJS. The problem is that the program still continues on to the terminateAppHandler
in base.js.
This is what I got so far:
WinJS.Application.onerror = function (customEventObject) {
// Get the error message and name for this exception
var errorMessage = customEventObject.detail.error.message;
var errorName = customEventObject.detail.error.name;
// Bind them in an optionsObject to pass with the navigation
var optionsObject = { errName: errorName, errMsg: errorMessage };
// Navigate home with information concerning the error
WinJS.Navigation.navigate("/pages/home/home.html", optionsObject);
// Need something to tell Windows that the error is "taken care" of
return false; // ??
}
I end up here, terminating the app:
var terminateAppHandler = function (data) {
debugger;
MSApp.terminateApp(data);
};
Any suggestions or input is more then welcome!
Return true instead of false.
You'll also want to hook up to window.onerror for exceptions that aren't sent through application.onerror. Although if an exception gets there, it's truly unhandled, and there's no predicting what state the app is in.