35e2ed1e57
BUG= http://dartbug.com/11279 R=lrn@google.com Review URL: https://codereview.chromium.org//23875032 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@27802 260f80e4-7a28-3924-810f-c04153c831b5
20 lines
326 B
Dart
20 lines
326 B
Dart
library catch_errors;
|
|
|
|
import 'dart:async';
|
|
|
|
Stream catchErrors(void body()) {
|
|
StreamController controller;
|
|
|
|
bool onError(e) {
|
|
controller.add(e);
|
|
return true;
|
|
}
|
|
|
|
void onListen() {
|
|
runZoned(body, onError: onError);
|
|
}
|
|
|
|
controller = new StreamController(onListen: onListen);
|
|
return controller.stream;
|
|
}
|