Skip to content

Instantly share code, notes, and snippets.

@fnobi
Created October 10, 2013 06:46
Show Gist options
  • Save fnobi/6914089 to your computer and use it in GitHub Desktop.
Save fnobi/6914089 to your computer and use it in GitHub Desktop.
phantomjsで出るエラーだけ追うスクリプト ref: http://qiita.com/fnobi/items/fdcd302c487d1b277246
var system = require('system');
var url = system.args[1];
if (!/^https?:\/\//.test(url)) {
console.error('Pass a url!');
phantom.exit();
}
phantom.onError = function(msg, trace) {
var msgStack = ['PHANTOM ERROR: ' + msg];
if (trace && trace.length) {
msgStack.push('TRACE:');
trace.forEach(function(t) {
msgStack.push(' -> ' + (t.file || t.sourceURL) + ': ' + t.line + (t.function ? ' (in function ' + t.function + ')' : ''));
});
}
console.error(msgStack.join('\n'));
phantom.exit(1);
};
var page = require('webpage').create();
// page.viewportSize = { width: 320, height: 480 };
page.open(url, function (status) {
if (status !== 'success') {
console.error('Unable to access the network!');
phantom.exit(1);
}
// phantom.exit();
});
phantomjs errortracker.js http://fnobi.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment