Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: third_party/pkg/angular/lib/mock/exception_handler.dart

Issue 180843004: Revert revision 33053 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.mock; 1 part of angular.mock;
2 2
3 /** 3 /**
4 * Mock implementation of [ExceptionHandler] that rethrows exceptions. 4 * Mock implementation of [ExceptionHandler] that rethrows exceptions.
5 */ 5 */
6 class RethrowExceptionHandler extends ExceptionHandler { 6 class RethrowExceptionHandler extends ExceptionHandler {
7 call(error, stack, [reason]){ 7 call(error, stack, [reason]){
8 throw "$error $reason \nORIGINAL STACKTRACE:\n $stack"; 8 throw "$error $reason \nORIGINAL STACKTRACE:\n $stack";
9 } 9 }
10 } 10 }
11 11
12 class ExceptionWithStack { 12 class ExceptionWithStack {
13 final dynamic error; 13 final dynamic error;
14 final dynamic stack; 14 final dynamic stack;
15 ExceptionWithStack(this.error, this.stack); 15 ExceptionWithStack(this.error, this.stack);
16 toString() => "$error\n$stack"; 16 toString() => "$error\n$stack";
17 } 17 }
18 18
19 /** 19 /**
20 * Mock implementation of [ExceptionHandler] that logs all exceptions for 20 * Mock implementation of [ExceptionHandler] that logs all exceptions for
21 * later processing. 21 * later processing.
22 */ 22 */
23 class LoggingExceptionHandler implements ExceptionHandler { 23 class LoggingExceptionHandler implements ExceptionHandler {
24 /** 24 /**
25 * All exceptions are stored here for later examining. 25 * All exceptions are stored here for later examining.
26 */ 26 */
27 final errors = <ExceptionWithStack>[]; 27 final List<ExceptionWithStack> errors = [];
28 28
29 call(error, stack, [reason]) { 29 call(error, stack, [reason]) {
30 errors.add(new ExceptionWithStack(error, stack)); 30 errors.add(new ExceptionWithStack(error, stack));
31 } 31 }
32 32
33 /** 33 /**
34 * This method throws an exception if the errors is not empty. 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 35 * It is recommended that this method is called on test tear-down
36 * to verify that all exceptions have been processed. 36 * to verify that all exceptions have been processed.
37 */ 37 */
38 assertEmpty() { 38 assertEmpty() {
39 if (errors.isNotEmpty) { 39 if (errors.length > 0) {
40 throw new ArgumentError('Exception Logger not empty:\n$errors'); 40 throw new ArgumentError('Exception Logger not empty:\n$errors');
41 } 41 }
42 } 42 }
43 } 43 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/mock/debug.dart ('k') | third_party/pkg/angular/lib/mock/http_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698