blob: c289690eb1741570891668144f9f222ab04e4b66 [file] [log] [blame]
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;
}