From fd626950de55081f5061b241ce1eaaebaac2abe6 Mon Sep 17 00:00:00 2001 From: minie4 Date: Wed, 3 Jul 2024 11:05:48 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Properly=20display=20error=20res?= =?UTF-8?q?ponses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 84eaaab..fd65950 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -111,6 +111,29 @@ class _GoMixHomeState extends State { } }); } + + if (data["type"] == "error") { + String errorMessage = ""; + try { + errorMessage = data["responseData"]["error"]; + } catch (e) { + errorMessage = "Unknown error"; + } + + showDialog( + context: context, + builder: (BuildContext context) => AlertDialog( + title: const Text('Server error'), + content: Text(errorMessage), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context, 'OK'), + child: const Text('OK'), + ), + ], + ), + ); + } }, onDone: () { wsConnected = false; if (connectionError.value != "") return;