Commit 76b7f73f 76b7f73fc098892c31d3df15181d3710b857d573 by Nicolas Perriault

fixed #547 - emit error event when step and complete callbacks fail

1 parent 16e085cc
......@@ -66,6 +66,21 @@ Emitted when a :index:`screenshot` image has been captured.
Emitted when the ``Casper.click()`` method has been called.
``complete.error``
~~~~~~~~~~~~~~~~~~
**Arguments:** ``error``
.. versionadded:: 1.1
Emitted when a complete callback has errored.
By default, CasperJS doesn't listen to this event, you have to declare your own listeners by hand::
casper.on('complete.error', function(err) {
this.die("Complete callback has failed: " + err);
});
``die``
~~~~~~~
......@@ -91,7 +106,7 @@ Emitted when a file has been downloaded by :ref:`Casper.download() <casper_downl
.. versionadded:: 0.6.9
Emitted when an error hasn't been caught. Do basically what PhantomJS' ``onError()`` native handler does.
Emitted when an error hasn't been explicitly caught within the CasperJS/PhantomJS environment. Do basically what PhantomJS' ``onError()`` native handler does.
.. index:: exit
......@@ -397,6 +412,21 @@ Emitted when a navigation step has been executed.
Emitted when a new navigation step has been created.
``step.error``
~~~~~~~~~~~~~~
**Arguments:** ``error``
.. versionadded:: 1.1
Emitted when a step function has errored.
By default, CasperJS doesn't listen to this event, you have to declare your own listeners by hand::
casper.on('step.error', function(err) {
this.die("Step has failed: " + err);
});
``step.start``
~~~~~~~~~~~~~~
......
......@@ -5,7 +5,7 @@
Installation
============
CasperJS can be installed on most Linuxes, OSX and Windows.
CasperJS can be installed on Mac OSX, Windows and most Linuxes.
Prerequisites
-------------
......@@ -30,7 +30,7 @@ Prerequisites
Installing from Homebrew (OSX)
------------------------------
Installation of both PhantomJS and CasperJS can be achieved through `Homebrew <http://mxcl.github.com/homebrew/>`_.
Installation of both PhantomJS and CasperJS can be achieved using Homebrew_, a popular package manager for Mac OS X.
For the 1.1 development version (recommended)::
......@@ -155,6 +155,7 @@ Known Bugs & Limitations
- Due to its asynchronous nature, CasperJS doesn't work well with `PhantomJS' REPL <http://code.google.com/p/phantomjs/wiki/InteractiveModeREPL>`_.
.. _Homebrew: http://mxcl.github.com/homebrew/
.. _PhantomJS: http://phantomjs.org/
.. _Python: http://python.org/
.. _SlimerJS: http://slimerjs.org/
......
......@@ -380,6 +380,7 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) {
}
} catch (error) {
self.emit('complete.error', error);
this.emit('error', error);
}
};
......@@ -1526,6 +1527,7 @@ Casper.prototype.runStep = function runStep(step) {
}
} catch (err) {
this.emit('step.error', err);
this.emit('error', err);
}
if (!skipLog) {
this.emit('step.complete', stepResult);
......