| OLD | NEW |
| (Empty) | |
| 1 part of angular.mock; |
| 2 |
| 3 /** |
| 4 * Mock implementation of [ExceptionHandler] that rethrows exceptions. |
| 5 */ |
| 6 class RethrowExceptionHandler extends ExceptionHandler { |
| 7 call(error, stack, [reason]){ |
| 8 throw "$error $reason \nORIGINAL STACKTRACE:\n $stack"; |
| 9 } |
| 10 } |
| 11 |
| 12 class ExceptionWithStack { |
| 13 final dynamic error; |
| 14 final dynamic stack; |
| 15 ExceptionWithStack(this.error, this.stack); |
| 16 toString() => "$error\n$stack"; |
| 17 } |
| 18 |
| 19 /** |
| 20 * Mock implementation of [ExceptionHandler] that logs all exceptions for |
| 21 * later processing. |
| 22 */ |
| 23 class LoggingExceptionHandler implements ExceptionHandler { |
| 24 /** |
| 25 * All exceptions are stored here for later examining. |
| 26 */ |
| 27 final List<ExceptionWithStack> errors = []; |
| 28 |
| 29 call(error, stack, [reason]) { |
| 30 errors.add(new ExceptionWithStack(error, stack)); |
| 31 } |
| 32 |
| 33 /** |
| 34 * This method throws an exception if the errors is not empty. |
| 35 * It is recommended that this method is called on test tear-down |
| 36 * to verify that all exceptions have been processed. |
| 37 */ |
| 38 assertEmpty() { |
| 39 if (errors.length > 0) { |
| 40 throw new ArgumentError('Exception Logger not empty:\n$errors'); |
| 41 } |
| 42 } |
| 43 } |
| OLD | NEW |