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

Side by Side Diff: sdk/lib/async/stream_controller.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.async; 5 part of dart.async;
6 6
7 // ------------------------------------------------------------------- 7 // -------------------------------------------------------------------
8 // Controller for creating and adding events to a stream. 8 // Controller for creating and adding events to a stream.
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 * handle their own pausing. 161 * handle their own pausing.
162 */ 162 */
163 bool get isPaused; 163 bool get isPaused;
164 164
165 /** Whether there is a subscriber on the [Stream]. */ 165 /** Whether there is a subscriber on the [Stream]. */
166 bool get hasListener; 166 bool get hasListener;
167 167
168 /** 168 /**
169 * Send or enqueue an error event. 169 * Send or enqueue an error event.
170 * 170 *
171 * The [error] must not be `null`.
172 *
171 * Also allows an objection stack trace object, on top of what [EventSink] 173 * Also allows an objection stack trace object, on top of what [EventSink]
172 * allows. 174 * allows.
173 */ 175 */
174 void addError(Object error, [StackTrace stackTrace]); 176 void addError(Object error, [StackTrace stackTrace]);
175 177
176 /** 178 /**
177 * Receives events from [source] and puts them into this controller's stream. 179 * Receives events from [source] and puts them into this controller's stream.
178 * 180 *
179 * Returns a future which completes when the source stream is done. 181 * Returns a future which completes when the source stream is done.
180 * 182 *
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 */ 409 */
408 void add(T value) { 410 void add(T value) {
409 if (!_mayAddEvent) throw _badEventState(); 411 if (!_mayAddEvent) throw _badEventState();
410 _add(value); 412 _add(value);
411 } 413 }
412 414
413 /** 415 /**
414 * Send or enqueue an error event. 416 * Send or enqueue an error event.
415 */ 417 */
416 void addError(Object error, [StackTrace stackTrace]) { 418 void addError(Object error, [StackTrace stackTrace]) {
419 if (error == null) throw new ArgumentError("Error must not be null");
417 if (!_mayAddEvent) throw _badEventState(); 420 if (!_mayAddEvent) throw _badEventState();
418 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); 421 AsyncError replacement = Zone.current.errorCallback(error, stackTrace);
419 if (replacement != null) { 422 if (replacement != null) {
420 error = replacement.error; 423 error = replacement.error;
424 if (error == null) error = new NullThrownError();
421 stackTrace = replacement.stackTrace; 425 stackTrace = replacement.stackTrace;
422 } 426 }
423 _addError(error, stackTrace); 427 _addError(error, stackTrace);
424 } 428 }
425 429
426 /** 430 /**
427 * Closes this controller and sends a done event on the stream. 431 * Closes this controller and sends a done event on the stream.
428 * 432 *
429 * The first time a controller is closed, a "done" event is added to its 433 * The first time a controller is closed, a "done" event is added to its
430 * stream. 434 * stream.
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 _StreamControllerAddStreamState(_StreamController controller, 795 _StreamControllerAddStreamState(_StreamController controller,
792 this.varData, 796 this.varData,
793 Stream source, 797 Stream source,
794 bool cancelOnError) 798 bool cancelOnError)
795 : super(controller, source, cancelOnError) { 799 : super(controller, source, cancelOnError) {
796 if (controller.isPaused) { 800 if (controller.isPaused) {
797 addSubscription.pause(); 801 addSubscription.pause();
798 } 802 }
799 } 803 }
800 } 804 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698