Question

I tried using Zombie.js with the promises pattern instead of callbacks. The only problem was that when any javascript error (even non relevant ones) that occurred on the page's javascript, the promise would get rejected, not continuing the chain. I can't just disable the script execution of that page because it's important for what I'm doing.

Does anyone know any solution for this problem?

Thank you very much.

Était-ce utile?

La solution

Why not catch the failure and continue?

functionReturnsPromiseMightThrowError
    .then(
        null,
        function(e) {
            console.log("An error occurred deep within func", e, "continuing");
        }
    )
    .then(doOtherStuff)
;

The point is that, a rejection handler, if present, will be invoked, but the resulting promise is considered to have been fulfilled (after all, the error has now been "successfully" handled), and subsequent thens will invoke their success handler.

Autres conseils

Use try/catch blocks in place where you have errors http://www.w3schools.com/js/js_errors.asp

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top