Вопрос

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