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