Skip to content

Commit

Permalink
added onError handing for phantomjs to avoid page errors being passed…
Browse files Browse the repository at this point in the history
… through
  • Loading branch information
naltatis committed Jan 26, 2013
1 parent 9c6900b commit 426ef7e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/phantomjs/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ urls.forEach(function (url) {
page.onConsoleMessage = function (msg) {
console.log(msg);
};
page.onError = function (msg) {
console.error(msg);
};
} else {
page.onConsoleMessage = function (msg, line, source) {
console.log(JSON.stringify({
Expand All @@ -180,7 +183,17 @@ urls.forEach(function (url) {
source: source
}, null, 4));
};
page.onError = function (msg, trace) {
console.error(JSON.stringify({
message: msg,
stacktrace: trace
}));
};
}
} else {
page.onError = function () {
// catch uncaught error from the page
};
}

// set user agent string
Expand Down

0 comments on commit 426ef7e

Please sign in to comment.