From 1e7bcd7500a271e16bb1260ebb751bbd2ac55e3b Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 13 Mar 2025 23:53:03 +0100 Subject: [PATCH] fix: error handling and UI adjustment, removed "flutter version manager" support from settings.json --- .vscode/settings.json | 5 ++--- .../presentation/screens/event_sockets_view.dart | 10 +++++++--- .../data/repository/wsprotocol_repo_impl.dart | 9 ++++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e2b1de3..f4607f2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,3 @@ { - "dart.lineLength": 120, - "dart.flutterSdkPath": ".fvm/versions/3.27.1" -} \ No newline at end of file + "dart.lineLength": 120 +} diff --git a/lib/features/event_sockets/presentation/screens/event_sockets_view.dart b/lib/features/event_sockets/presentation/screens/event_sockets_view.dart index ac5cd9a..93b550e 100644 --- a/lib/features/event_sockets/presentation/screens/event_sockets_view.dart +++ b/lib/features/event_sockets/presentation/screens/event_sockets_view.dart @@ -126,15 +126,19 @@ class _EventSocketsViewState extends State { Icon(Iconsax.warning_2, color: Colors.amber), Text( "Check your socket parameters before connecting to websocket", - style: TextStyle(fontStyle: FontStyle.italic, fontWeight: FontWeight.bold), + style: TextStyle(fontWeight: FontWeight.bold), ), ], ), Container( width: size.width * 0.4, - height: size.height * 0.2, + height: size.height * 0.3, padding: EdgeInsets.symmetric(horizontal: 20), - color: Colors.grey.shade200, + decoration: BoxDecoration( + color: Colors.grey.shade300, + borderRadius: BorderRadius.circular(10), + border: Border.all(color: Colors.grey.shade400), + ), child: JsonEditorTheme( themeData: JsonEditorThemeData(lightTheme: JsonTheme.light()), child: JsonEditor.object( diff --git a/lib/features/wsprotocol/data/repository/wsprotocol_repo_impl.dart b/lib/features/wsprotocol/data/repository/wsprotocol_repo_impl.dart index 9118bba..216436f 100644 --- a/lib/features/wsprotocol/data/repository/wsprotocol_repo_impl.dart +++ b/lib/features/wsprotocol/data/repository/wsprotocol_repo_impl.dart @@ -26,7 +26,14 @@ class WsprotocolRepoImpl { }, onError: (error) { // Forward errors to listeners. - _messageController.addError(error); + // _messageController.addError(error); + // Extract error message + final String errorMessage = error is WebSocketChannelException + ? 'WebSocket Error: ${error.inner}' + : 'Unknown WebSocket Error: $error'; + + // Forward a structured error message + _messageController.addError(errorMessage); }, onDone: () { // Optionally notify listeners that the connection has closed.