From 9cd077f0d22e39276824a2577f9b138b1b71c337 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Tue, 4 Feb 2014 16:29:04 +0000 Subject: [PATCH] display HTTP errors and give up page.open(url, function (status) checks only for network errors, and will return 'success' for HTTP 404. We must check onResourceError too --- test/phantom/evaluate.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/phantom/evaluate.js b/test/phantom/evaluate.js index ccf01e4..8cc4c3e 100644 --- a/test/phantom/evaluate.js +++ b/test/phantom/evaluate.js @@ -76,12 +76,18 @@ page.onAlert = function (msg) { console.log("Alert: " + msg); }; +// display HTTP errors +page.onResourceError = function (resourceError) { + // console.log('phantomjs error code: ' + resourceError.errorCode); + console.log(resourceError.errorString); + phantom.exit(3); +}; page.open(url, function (status) { if (debug >= 1) console.log("fetch " + url + " with status: " + status); if (status != 'success') { - console.log("Failed to fetch page, give up"); + console.log("Failed to fetch page, give up. Network error?"); phantom.exit(1); } -- 1.7.10.4