locked
Swallow errors in Exception chain and ensure code is executed

    Question

  • I have code that enables the appbars of the app after the extended splashscreen has been dismissed.

    I fadeOutAsync the splashscreen element and after it has been faded out I want to enable the appbars again.

    Now I don't care if fadeOutAsync runs into an error, I always want to enable the appbars when the fading is done, either via continuation or error handler.#

    What I came up with is this:

    remove = function() {
      var fadePromise, splashElement;
      fadePromise = (splashElement = document.getElementById("splashScreen")) ? WinJS.UI.Animation.fadeOut(splashElement) : WinJS.Promise.as();
      fadePromise.then(null, function() {}) // Swallow the error
    .done(function() { if (splashElement != null) { splashElement.parentElement.removeChild(splashElement); } logger.debug("SplashScreen removed"); disableAppBars(false); }); };

    Is this the recommended way?

    Wednesday, June 11, 2014 8:57 PM

All replies

  • Look ok to me.  You might try explicitly calling a function which throws an exception just to test.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, June 12, 2014 1:27 PM
    Moderator