fixed #547 - emit error event when step and complete callbacks fail
Showing
3 changed files
with
36 additions
and
3 deletions
... | @@ -66,6 +66,21 @@ Emitted when a :index:`screenshot` image has been captured. | ... | @@ -66,6 +66,21 @@ Emitted when a :index:`screenshot` image has been captured. |
66 | 66 | ||
67 | Emitted when the ``Casper.click()`` method has been called. | 67 | Emitted when the ``Casper.click()`` method has been called. |
68 | 68 | ||
69 | ``complete.error`` | ||
70 | ~~~~~~~~~~~~~~~~~~ | ||
71 | |||
72 | **Arguments:** ``error`` | ||
73 | |||
74 | .. versionadded:: 1.1 | ||
75 | |||
76 | Emitted when a complete callback has errored. | ||
77 | |||
78 | By default, CasperJS doesn't listen to this event, you have to declare your own listeners by hand:: | ||
79 | |||
80 | casper.on('complete.error', function(err) { | ||
81 | this.die("Complete callback has failed: " + err); | ||
82 | }); | ||
83 | |||
69 | ``die`` | 84 | ``die`` |
70 | ~~~~~~~ | 85 | ~~~~~~~ |
71 | 86 | ||
... | @@ -91,7 +106,7 @@ Emitted when a file has been downloaded by :ref:`Casper.download() <casper_downl | ... | @@ -91,7 +106,7 @@ Emitted when a file has been downloaded by :ref:`Casper.download() <casper_downl |
91 | 106 | ||
92 | .. versionadded:: 0.6.9 | 107 | .. versionadded:: 0.6.9 |
93 | 108 | ||
94 | Emitted when an error hasn't been caught. Do basically what PhantomJS' ``onError()`` native handler does. | 109 | Emitted when an error hasn't been explicitly caught within the CasperJS/PhantomJS environment. Do basically what PhantomJS' ``onError()`` native handler does. |
95 | 110 | ||
96 | .. index:: exit | 111 | .. index:: exit |
97 | 112 | ||
... | @@ -397,6 +412,21 @@ Emitted when a navigation step has been executed. | ... | @@ -397,6 +412,21 @@ Emitted when a navigation step has been executed. |
397 | 412 | ||
398 | Emitted when a new navigation step has been created. | 413 | Emitted when a new navigation step has been created. |
399 | 414 | ||
415 | ``step.error`` | ||
416 | ~~~~~~~~~~~~~~ | ||
417 | |||
418 | **Arguments:** ``error`` | ||
419 | |||
420 | .. versionadded:: 1.1 | ||
421 | |||
422 | Emitted when a step function has errored. | ||
423 | |||
424 | By default, CasperJS doesn't listen to this event, you have to declare your own listeners by hand:: | ||
425 | |||
426 | casper.on('step.error', function(err) { | ||
427 | this.die("Step has failed: " + err); | ||
428 | }); | ||
429 | |||
400 | ``step.start`` | 430 | ``step.start`` |
401 | ~~~~~~~~~~~~~~ | 431 | ~~~~~~~~~~~~~~ |
402 | 432 | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | Installation | 5 | Installation |
6 | ============ | 6 | ============ |
7 | 7 | ||
8 | CasperJS can be installed on most Linuxes, OSX and Windows. | 8 | CasperJS can be installed on Mac OSX, Windows and most Linuxes. |
9 | 9 | ||
10 | Prerequisites | 10 | Prerequisites |
11 | ------------- | 11 | ------------- |
... | @@ -30,7 +30,7 @@ Prerequisites | ... | @@ -30,7 +30,7 @@ Prerequisites |
30 | Installing from Homebrew (OSX) | 30 | Installing from Homebrew (OSX) |
31 | ------------------------------ | 31 | ------------------------------ |
32 | 32 | ||
33 | Installation of both PhantomJS and CasperJS can be achieved through `Homebrew <http://mxcl.github.com/homebrew/>`_. | 33 | Installation of both PhantomJS and CasperJS can be achieved using Homebrew_, a popular package manager for Mac OS X. |
34 | 34 | ||
35 | For the 1.1 development version (recommended):: | 35 | For the 1.1 development version (recommended):: |
36 | 36 | ||
... | @@ -155,6 +155,7 @@ Known Bugs & Limitations | ... | @@ -155,6 +155,7 @@ Known Bugs & Limitations |
155 | 155 | ||
156 | - Due to its asynchronous nature, CasperJS doesn't work well with `PhantomJS' REPL <http://code.google.com/p/phantomjs/wiki/InteractiveModeREPL>`_. | 156 | - Due to its asynchronous nature, CasperJS doesn't work well with `PhantomJS' REPL <http://code.google.com/p/phantomjs/wiki/InteractiveModeREPL>`_. |
157 | 157 | ||
158 | .. _Homebrew: http://mxcl.github.com/homebrew/ | ||
158 | .. _PhantomJS: http://phantomjs.org/ | 159 | .. _PhantomJS: http://phantomjs.org/ |
159 | .. _Python: http://python.org/ | 160 | .. _Python: http://python.org/ |
160 | .. _SlimerJS: http://slimerjs.org/ | 161 | .. _SlimerJS: http://slimerjs.org/ | ... | ... |
... | @@ -380,6 +380,7 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) { | ... | @@ -380,6 +380,7 @@ Casper.prototype.checkStep = function checkStep(self, onComplete) { |
380 | } | 380 | } |
381 | } catch (error) { | 381 | } catch (error) { |
382 | self.emit('complete.error', error); | 382 | self.emit('complete.error', error); |
383 | this.emit('error', error); | ||
383 | } | 384 | } |
384 | }; | 385 | }; |
385 | 386 | ||
... | @@ -1526,6 +1527,7 @@ Casper.prototype.runStep = function runStep(step) { | ... | @@ -1526,6 +1527,7 @@ Casper.prototype.runStep = function runStep(step) { |
1526 | } | 1527 | } |
1527 | } catch (err) { | 1528 | } catch (err) { |
1528 | this.emit('step.error', err); | 1529 | this.emit('step.error', err); |
1530 | this.emit('error', err); | ||
1529 | } | 1531 | } |
1530 | if (!skipLog) { | 1532 | if (!skipLog) { |
1531 | this.emit('step.complete', stepResult); | 1533 | this.emit('step.complete', stepResult); | ... | ... |
-
Please register or sign in to post a comment