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

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

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698