Anyways, I'm getting started with casperjs, and I want to handle error events using the casper.on('error', ...). I'm on windows 7, 64-bit
Problem is that when doing this, and when an error is triggered, casperjs/phantomjs goes into a loop and doesn't process the exit/die.
Here's the sample code: (I intentionally comment out the 'var keywords' to test it out):
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});
casper.start();
casper.then(function () {
casper.echo('breaking down keywords');
//var keywords = []; //comment out to test for error handling
keywords.push('hello world');
casper.echo('finished');
});
casper.on('error', function (msg, backtrace) {
this.echo("=========================");
this.echo("ERROR:");
this.echo(msg);
this.echo(backtrace);
this.echo("=========================");
this.die("die");
});
casper.run();
Here's an image: http://prntscr.com/71aiuu
that infinite loop goes on and on and fills the console. I thought that the simple 'casper/this.die' will do its thing.
I also looked at the other issues like phantomjs exit() doesn't terminate the process, but I only have intel hd graphics.
Any recommendations on what I should do?