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 = StreamController.broadcast(sync: true); RawReceivePort? port; void handleError(Object? message) { var listMessage = message as List<Object?>; var errorDescription = listMessage[0] as String; var stackDescription = listMessage[1] as String; var error = new RemoteError(errorDescription, stackDescription); controller.addError(error, error.stackTrace); } controller.onListen = () { RawReceivePort receivePort = new RawReceivePort(handleError); port = receivePort; this.addErrorListener(receivePort.sendPort); }; controller.onCancel = () { var listenPort = port!; port = null; this.removeErrorListener(listenPort.sendPort); listenPort.close(); }; return controller.stream; }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-isolate/Isolate/errors.html