throw real exceptions instead of die() when it makes sense
Showing
1 changed file
with
6 additions
and
6 deletions
... | @@ -1687,10 +1687,10 @@ Casper.prototype.wait = function wait(timeout, then) { | ... | @@ -1687,10 +1687,10 @@ Casper.prototype.wait = function wait(timeout, then) { |
1687 | this.checkStarted(); | 1687 | this.checkStarted(); |
1688 | timeout = ~~timeout; | 1688 | timeout = ~~timeout; |
1689 | if (timeout < 1) { | 1689 | if (timeout < 1) { |
1690 | this.die("wait() only accepts a positive integer > 0 as a timeout value"); | 1690 | throw new CasperError("wait() only accepts a positive integer > 0 as a timeout value"); |
1691 | } | 1691 | } |
1692 | if (then && !utils.isFunction(then)) { | 1692 | if (then && !utils.isFunction(then)) { |
1693 | this.die("wait() a step definition must be a function"); | 1693 | throw new CasperError("wait() a step definition must be a function"); |
1694 | } | 1694 | } |
1695 | return this.then(function _step() { | 1695 | return this.then(function _step() { |
1696 | this.waitStart(); | 1696 | this.waitStart(); |
... | @@ -1730,10 +1730,10 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { | ... | @@ -1730,10 +1730,10 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { |
1730 | this.checkStarted(); | 1730 | this.checkStarted(); |
1731 | timeout = timeout ? timeout : this.options.waitTimeout; | 1731 | timeout = timeout ? timeout : this.options.waitTimeout; |
1732 | if (!utils.isFunction(testFx)) { | 1732 | if (!utils.isFunction(testFx)) { |
1733 | this.die("waitFor() needs a test function"); | 1733 | throw new CasperError("waitFor() needs a test function"); |
1734 | } | 1734 | } |
1735 | if (then && !utils.isFunction(then)) { | 1735 | if (then && !utils.isFunction(then)) { |
1736 | this.die("waitFor() next step definition must be a function"); | 1736 | throw new CasperError("waitFor() next step definition must be a function"); |
1737 | } | 1737 | } |
1738 | return this.then(function _step() { | 1738 | return this.then(function _step() { |
1739 | this.waitStart(); | 1739 | this.waitStart(); |
... | @@ -1742,7 +1742,8 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { | ... | @@ -1742,7 +1742,8 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { |
1742 | var interval = setInterval(function _check(self, testFx, timeout, onTimeout) { | 1742 | var interval = setInterval(function _check(self, testFx, timeout, onTimeout) { |
1743 | if ((new Date().getTime() - start < timeout) && !condition) { | 1743 | if ((new Date().getTime() - start < timeout) && !condition) { |
1744 | condition = testFx.call(self, self); | 1744 | condition = testFx.call(self, self); |
1745 | } else { | 1745 | return; |
1746 | } | ||
1746 | self.waitDone(); | 1747 | self.waitDone(); |
1747 | if (!condition) { | 1748 | if (!condition) { |
1748 | self.log("Casper.waitFor() timeout", "warning"); | 1749 | self.log("Casper.waitFor() timeout", "warning"); |
... | @@ -1759,7 +1760,6 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { | ... | @@ -1759,7 +1760,6 @@ Casper.prototype.waitFor = function waitFor(testFx, then, onTimeout, timeout) { |
1759 | } | 1760 | } |
1760 | } | 1761 | } |
1761 | clearInterval(interval); | 1762 | clearInterval(interval); |
1762 | } | ||
1763 | }, 100, this, testFx, timeout, onTimeout); | 1763 | }, 100, this, testFx, timeout, onTimeout); |
1764 | }); | 1764 | }); |
1765 | }; | 1765 | }; | ... | ... |
-
Please register or sign in to post a comment