문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top