OLD | NEW |
---|---|
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 /// Helper functionality to make working with IO easier. | 5 /// Helper functionality to make working with IO easier. |
6 library pub.io; | 6 library pub.io; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 /// | 455 /// |
456 /// When an error occurs on [stream], that error is passed to [sink]. If | 456 /// When an error occurs on [stream], that error is passed to [sink]. If |
457 /// [cancelOnError] is true, [Future] will be completed successfully and no | 457 /// [cancelOnError] is true, [Future] will be completed successfully and no |
458 /// more data or errors will be piped from [stream] to [sink]. If | 458 /// more data or errors will be piped from [stream] to [sink]. If |
459 /// [cancelOnError] and [closeSink] are both true, [sink] will then be | 459 /// [cancelOnError] and [closeSink] are both true, [sink] will then be |
460 /// closed. | 460 /// closed. |
461 Future store(Stream stream, EventSink sink, | 461 Future store(Stream stream, EventSink sink, |
462 {bool cancelOnError: true, bool closeSink: true}) { | 462 {bool cancelOnError: true, bool closeSink: true}) { |
463 var completer = new Completer(); | 463 var completer = new Completer(); |
464 stream.listen(sink.add, | 464 stream.listen(sink.add, |
465 onError: (e) { | 465 onError: (e, [StackTrace stackTrace]) { |
466 // TODO(floitsch): Sink.addError without stack trace. | |
Lasse Reichstein Nielsen
2013/10/04 08:45:17
What is the solution?
Should EventSink.addError ha
floitsch
2013/10/05 18:11:48
Yes. See follow-up CLs.
This is one of the reasons
| |
466 sink.addError(e); | 467 sink.addError(e); |
467 if (cancelOnError) { | 468 if (cancelOnError) { |
468 completer.complete(); | 469 completer.complete(); |
469 if (closeSink) sink.close(); | 470 if (closeSink) sink.close(); |
470 } | 471 } |
471 }, | 472 }, |
472 onDone: () { | 473 onDone: () { |
473 if (closeSink) sink.close(); | 474 if (closeSink) sink.close(); |
474 completer.complete(); | 475 completer.complete(); |
475 }, cancelOnError: cancelOnError); | 476 }, cancelOnError: cancelOnError); |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 833 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
833 | 834 |
834 bool get success => exitCode == 0; | 835 bool get success => exitCode == 0; |
835 } | 836 } |
836 | 837 |
837 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 838 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
838 Uri _getUri(uri) { | 839 Uri _getUri(uri) { |
839 if (uri is Uri) return uri; | 840 if (uri is Uri) return uri; |
840 return Uri.parse(uri); | 841 return Uri.parse(uri); |
841 } | 842 } |
OLD | NEW |