Skip to content

Commit 7203465

Browse files
committed
fix 1825: wrap decoding in try/catch
1 parent e0dadd1 commit 7203465

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkgs/cupertino_http/lib/src/cupertino_web_socket.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ class CupertinoWebSocket implements WebSocket {
203203

204204
void _connectionClosed(int? closeCode, objc.NSData? reason) {
205205
if (!_events.isClosed) {
206-
final closeReason = reason == null ? '' : utf8.decode(reason.toList());
206+
String closeReason;
207+
208+
try {
209+
closeReason = reason == null ? '' : utf8.decode(reason.toList());
210+
} on FormatException {
211+
closeReason = 'unknown';
212+
}
207213

208214
_events
209215
..add(CloseReceived(closeCode, closeReason))

0 commit comments

Comments
 (0)