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

Unified Diff: sdk/lib/async/future.dart

Issue 598993002: Add missing null-tests to async error functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698