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

Side by Side Diff: sdk/lib/async/stream.dart

Issue 2467453002: Fix docs for `Stream.handleError`. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Core Stream types 8 // Core Stream types
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 sync: true 504 sync: true
505 ); 505 );
506 } 506 }
507 return controller.stream; 507 return controller.stream;
508 } 508 }
509 509
510 /** 510 /**
511 * Creates a wrapper Stream that intercepts some errors from this stream. 511 * Creates a wrapper Stream that intercepts some errors from this stream.
512 * 512 *
513 * If this stream sends an error that matches [test], then it is intercepted 513 * If this stream sends an error that matches [test], then it is intercepted
514 * by the [handle] function. 514 * by the [onError] function.
515 * 515 *
516 * The [onError] callback must be of type `void onError(error)` or 516 * The [onError] callback must be of type `void onError(error)` or
517 * `void onError(error, StackTrace stackTrace)`. Depending on the function 517 * `void onError(error, StackTrace stackTrace)`. Depending on the function
518 * type the stream either invokes [onError] with or without a stack 518 * type the stream either invokes [onError] with or without a stack
519 * trace. The stack trace argument might be `null` if the stream itself 519 * trace. The stack trace argument might be `null` if the stream itself
520 * received an error without stack trace. 520 * received an error without stack trace.
521 * 521 *
522 * An asynchronous error [:e:] is matched by a test function if [:test(e):] 522 * An asynchronous error `error` is matched by a test function if
523 * returns true. If [test] is omitted, every error is considered matching. 523 *`test(error)` returns true. If [test] is omitted, every error is considered
524 * matching.
524 * 525 *
525 * If the error is intercepted, the [handle] function can decide what to do 526 * If the error is intercepted, the [onError] function can decide what to do
526 * with it. It can throw if it wants to raise a new (or the same) error, 527 * with it. It can throw if it wants to raise a new (or the same) error,
527 * or simply return to make the stream forget the error. 528 * or simply return to make the stream forget the error.
528 * 529 *
529 * If you need to transform an error into a data event, use the more generic 530 * If you need to transform an error into a data event, use the more generic
530 * [Stream.transform] to handle the event by writing a data event to 531 * [Stream.transform] to handle the event by writing a data event to
531 * the output sink. 532 * the output sink.
532 * 533 *
533 * The returned stream is a broadcast stream if this stream is. 534 * The returned stream is a broadcast stream if this stream is.
534 * If a broadcast stream is listened to more than once, each subscription 535 * If a broadcast stream is listened to more than once, each subscription
535 * will individually perform the `test` and handle the error. 536 * will individually perform the `test` and handle the error.
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 class _ControllerEventSinkWrapper<T> implements EventSink<T> { 1827 class _ControllerEventSinkWrapper<T> implements EventSink<T> {
1827 EventSink _sink; 1828 EventSink _sink;
1828 _ControllerEventSinkWrapper(this._sink); 1829 _ControllerEventSinkWrapper(this._sink);
1829 1830
1830 void add(T data) { _sink.add(data); } 1831 void add(T data) { _sink.add(data); }
1831 void addError(error, [StackTrace stackTrace]) { 1832 void addError(error, [StackTrace stackTrace]) {
1832 _sink.addError(error, stackTrace); 1833 _sink.addError(error, stackTrace);
1833 } 1834 }
1834 void close() { _sink.close(); } 1835 void close() { _sink.close(); }
1835 } 1836 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698