errors property
Returns a broadcast stream of uncaught errors from the isolate.
Each error is provided as an error event on the stream.
The actual error object and stackTraces will not necessarily be the same object types as in the actual isolate, but they will always have the same Object.toString result.
This stream is based on addErrorListener and removeErrorListener.
Implementation
Stream get errors {
StreamController controller;
RawReceivePort port;
void handleError(message) {
List listMessage = message;
String errorDescription = listMessage[0];
String stackDescription = listMessage[1];
var error = new RemoteError(errorDescription, stackDescription);
controller.addError(error, error.stackTrace);
}
controller = new StreamController.broadcast(
sync: true,
onListen: () {
port = new RawReceivePort(handleError);
this.addErrorListener(port.sendPort);
},
onCancel: () {
this.removeErrorListener(port.sendPort);
port.close();
port = null;
});
return controller.stream;
}