2ae198d527
This reapplies commit r24034. This reapplies commit r24035. This reapplies commit r24036. This reapplies commit r24037. + some status file updates and fixes. Review URL: https://codereview.chromium.org//17098007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24064 260f80e4-7a28-3924-810f-c04153c831b5
30 lines
575 B
Dart
30 lines
575 B
Dart
library catch_errors;
|
|
|
|
import 'dart:async';
|
|
|
|
Stream catchErrors(void body()) {
|
|
StreamController controller;
|
|
|
|
bool onError(e) {
|
|
controller.add(e);
|
|
return true;
|
|
}
|
|
|
|
void onDone() {
|
|
controller.close();
|
|
}
|
|
|
|
void onListen() {
|
|
runZonedExperimental(body, onError: onError, onDone: onDone);
|
|
}
|
|
|
|
controller = new StreamController(onListen: onListen);
|
|
return controller.stream;
|
|
}
|
|
|
|
Future waitForCompletion(void body()) {
|
|
Completer completer = new Completer.sync();
|
|
runZonedExperimental(body, onDone: completer.complete);
|
|
return completer.future;
|
|
}
|