|
1 | 1 | /**
|
2 |
| - * @license AngularJS v1.3.8 |
| 2 | + * @license AngularJS v1.3.9 |
3 | 3 | * (c) 2010-2014 Google, Inc. http://angularjs.org
|
4 | 4 | * License: MIT
|
5 | 5 | */
|
@@ -250,31 +250,31 @@ angular.mock.$ExceptionHandlerProvider = function() {
|
250 | 250 | *
|
251 | 251 | * @param {string} mode Mode of operation, defaults to `rethrow`.
|
252 | 252 | *
|
253 |
| - * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there |
254 |
| - * is a bug in the application or test, so this mock will make these tests fail. |
255 | 253 | * - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log`
|
256 | 254 | * mode stores an array of errors in `$exceptionHandler.errors`, to allow later
|
257 | 255 | * assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
|
258 | 256 | * {@link ngMock.$log#reset reset()}
|
| 257 | + * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there |
| 258 | + * is a bug in the application or test, so this mock will make these tests fail. |
| 259 | + * For any implementations that expect exceptions to be thrown, the `rethrow` mode |
| 260 | + * will also maintain a log of thrown errors. |
259 | 261 | */
|
260 | 262 | this.mode = function(mode) {
|
| 263 | + |
261 | 264 | switch (mode) {
|
262 |
| - case 'rethrow': |
263 |
| - handler = function(e) { |
264 |
| - throw e; |
265 |
| - }; |
266 |
| - break; |
267 | 265 | case 'log':
|
| 266 | + case 'rethrow': |
268 | 267 | var errors = [];
|
269 |
| - |
270 | 268 | handler = function(e) {
|
271 | 269 | if (arguments.length == 1) {
|
272 | 270 | errors.push(e);
|
273 | 271 | } else {
|
274 | 272 | errors.push([].slice.call(arguments, 0));
|
275 | 273 | }
|
| 274 | + if (mode === "rethrow") { |
| 275 | + throw e; |
| 276 | + } |
276 | 277 | };
|
277 |
| - |
278 | 278 | handler.errors = errors;
|
279 | 279 | break;
|
280 | 280 | default:
|
|
0 commit comments