@@ -528,7 +528,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
528
528
s.setListening (read: false , write: false );
529
529
});
530
530
connecting.clear ();
531
- }, error: (e) {
531
+ }, error: (e, st ) {
532
532
timer.cancel ();
533
533
socket.close ();
534
534
// Keep first error, if present.
@@ -676,7 +676,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
676
676
if (len == 0 ) return null ;
677
677
var result = nativeRead (len);
678
678
if (result is OSError ) {
679
- reportError (result, "Read failed" );
679
+ reportError (result, StackTrace .current, "Read failed" );
680
680
return null ;
681
681
}
682
682
if (result != null ) {
@@ -699,7 +699,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
699
699
if (isClosing || isClosed) return null ;
700
700
var result = nativeRecvFrom ();
701
701
if (result is OSError ) {
702
- reportError (result, "Receive failed" );
702
+ reportError (result, StackTrace .current, "Receive failed" );
703
703
return null ;
704
704
}
705
705
if (result != null ) {
@@ -747,7 +747,8 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
747
747
nativeWrite (bufferAndStart.buffer, bufferAndStart.start, bytes);
748
748
if (result is OSError ) {
749
749
OSError osError = result;
750
- scheduleMicrotask (() => reportError (osError, "Write failed" ));
750
+ StackTrace st = StackTrace .current;
751
+ scheduleMicrotask (() => reportError (osError, st, "Write failed" ));
751
752
result = 0 ;
752
753
}
753
754
// The result may be negative, if we forced a short write for testing
@@ -776,7 +777,8 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
776
777
bytes, (address as _InternetAddress )._in_addr, port);
777
778
if (result is OSError ) {
778
779
OSError osError = result;
779
- scheduleMicrotask (() => reportError (osError, "Send failed" ));
780
+ StackTrace st = StackTrace .current;
781
+ scheduleMicrotask (() => reportError (osError, st, "Send failed" ));
780
782
result = 0 ;
781
783
}
782
784
// TODO(ricow): Remove when we track internal and pipe uses.
@@ -934,7 +936,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
934
936
935
937
if (i == errorEvent) {
936
938
if (! isClosing) {
937
- reportError (nativeGetError (), "" );
939
+ reportError (nativeGetError (), null , "" );
938
940
}
939
941
} else if (! isClosed) {
940
942
// If the connection is closed right after it's accepted, there's a
@@ -1092,11 +1094,11 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
1092
1094
}
1093
1095
}
1094
1096
1095
- void reportError (error, String message) {
1097
+ void reportError (error, StackTrace st, String message) {
1096
1098
var e = createError (error, message, address, localPort);
1097
1099
// Invoke the error handler if any.
1098
1100
if (eventHandlers[errorEvent] != null ) {
1099
- eventHandlers[errorEvent](e);
1101
+ eventHandlers[errorEvent](e, st );
1100
1102
}
1101
1103
// For all errors we close the socket
1102
1104
close ();
@@ -1242,8 +1244,8 @@ class _RawServerSocket extends Stream<RawSocket> implements RawServerSocket {
1242
1244
_controller.add (new _RawSocket (socket));
1243
1245
if (_controller.isPaused) return ;
1244
1246
}
1245
- }), error: zone.bindUnaryCallbackGuarded ((e) {
1246
- _controller.addError (e);
1247
+ }), error: zone.bindBinaryCallbackGuarded ((e, st ) {
1248
+ _controller.addError (e, st );
1247
1249
_controller.close ();
1248
1250
}), destroyed: () {
1249
1251
_controller.close ();
@@ -1346,8 +1348,8 @@ class _RawSocket extends Stream<RawSocketEvent> implements RawSocket {
1346
1348
_controller.add (RawSocketEvent .closed);
1347
1349
_controller.close ();
1348
1350
},
1349
- error: zone.bindUnaryCallbackGuarded ((e) {
1350
- _controller.addError (e);
1351
+ error: zone.bindBinaryCallbackGuarded ((e, st ) {
1352
+ _controller.addError (e, st );
1351
1353
_socket.close ();
1352
1354
}));
1353
1355
}
@@ -1889,8 +1891,8 @@ class _RawDatagramSocket extends Stream<RawSocketEvent>
1889
1891
_controller.add (RawSocketEvent .closed);
1890
1892
_controller.close ();
1891
1893
},
1892
- error: zone.bindUnaryCallbackGuarded ((e) {
1893
- _controller.addError (e);
1894
+ error: zone.bindBinaryCallbackGuarded ((e, st ) {
1895
+ _controller.addError (e, st );
1894
1896
_socket.close ();
1895
1897
}));
1896
1898
}
0 commit comments