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

Side by Side Diff: lib/src/result/error.dart

Issue 1777453002: Modernize the package's style. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 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
« no previous file with comments | « lib/src/result/capture_transformer.dart ('k') | lib/src/result/future.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6
7 import '../result.dart';
8 import 'value.dart';
9
10 /// A result representing a thrown error.
11 class ErrorResult implements Result {
12 final error;
13 final StackTrace stackTrace;
14
15 bool get isValue => false;
16 bool get isError => true;
17 ValueResult get asValue => null;
18 ErrorResult get asError => this;
19
20 ErrorResult(this.error, this.stackTrace);
21
22 void complete(Completer completer) {
23 completer.completeError(error, stackTrace);
24 }
25
26 void addTo(EventSink sink) {
27 sink.addError(error, stackTrace);
28 }
29
30 Future get asFuture => new Future.error(error, stackTrace);
31
32 /// Calls an error handler with the error and stacktrace.
33 ///
34 /// An async error handler function is either a function expecting two
35 /// arguments, which will be called with the error and the stack trace, or it
36 /// has to be a function expecting only one argument, which will be called
37 /// with only the error.
38 void handle(Function errorHandler) {
39 if (errorHandler is ZoneBinaryCallback) {
40 errorHandler(error, stackTrace);
41 } else {
42 errorHandler(error);
43 }
44 }
45 }
OLDNEW
« no previous file with comments | « lib/src/result/capture_transformer.dart ('k') | lib/src/result/future.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698