Chromium Code Reviews| Index: sdk/lib/async/future.dart |
| diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart |
| index a4971be56e435eadfe74a19b681376117065893b..179748d7c512219056faee595ac86bf3a954559a 100644 |
| --- a/sdk/lib/async/future.dart |
| +++ b/sdk/lib/async/future.dart |
| @@ -187,13 +187,17 @@ abstract class Future<T> { |
| /** |
| * A future that completes with an error in the next event-loop iteration. |
| * |
| - * Use [Completer] to create a Future and complete it later. |
| + * The [error] must not be `null`. |
| + * |
| + * Use [Completer] to create a future and complete it later. |
| */ |
| factory Future.error(Object error, [StackTrace stackTrace]) { |
| + if (error == null) throw new ArgumentError("Error must not be null"); |
|
floitsch
2014/09/24 12:59:14
Or make it an asynchronous "NullThrownError" ?
|
| if (!identical(Zone.current, _ROOT_ZONE)) { |
| AsyncError replacement = Zone.current.errorCallback(error, stackTrace); |
| if (replacement != null) { |
| error = replacement.error; |
| + if (error == null) error = new NullThrownError(); |
| stackTrace = replacement.stackTrace; |
| } |
| } |
| @@ -663,10 +667,11 @@ abstract class Completer<T> { |
| // for error replacement first. |
| void _completeWithErrorCallback(_Future result, error, stackTrace) { |
| AsyncError replacement = Zone.current.errorCallback(error, stackTrace); |
| - if (replacement == null) { |
| - result._completeError(error, stackTrace); |
| - } else { |
| - result._completeError(replacement.error, replacement.stackTrace); |
| + if (replacement != null) { |
| + error = replacement.error; |
| + if (error == null) error = new NullThrownError(); |
| + stackTrace = replacement.stackTrace; |
| } |
| + result._completeError(error, stackTrace); |
| } |