in those cases, we sometimes get ugly stack traces/exceptions, so
instead of just showing that and aborting, show a custom dialog with
the basic info that we could not save the password (+details box with
the original error) and continue instead.

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
 lib/proxmox_login_form.dart | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/lib/proxmox_login_form.dart b/lib/proxmox_login_form.dart
index e31d0c0..9c25126 100644
--- a/lib/proxmox_login_form.dart
+++ b/lib/proxmox_login_form.dart
@@ -527,10 +527,34 @@ class _ProxmoxLoginPageState extends 
State<ProxmoxLoginPage> {
       }
 
       if (id != null) {
-        if (savePW) {
-          await savePassword(id, enteredPassword);
-        } else if (deletePW) {
-          await deletePassword(id);
+        try {
+          if (savePW) {
+            await savePassword(id, enteredPassword);
+          } else if (deletePW) {
+            await deletePassword(id);
+          }
+        } catch (e) {
+          await showDialog(
+              context: context,
+              builder: (context) => AlertDialog(
+                    title: const Text('Password saving error'),
+                    scrollable: true,
+                    content: Column(
+                      mainAxisSize: MainAxisSize.min,
+                      children: [
+                        Text('Could not save or delete password.'),
+                        ExpansionTile(
+                          title: const Text('Details'),
+                          children: [Text(e.toString())],
+                        )
+                      ],
+                    ),
+                    actions: [
+                      TextButton(
+                          onPressed: () => Navigator.of(context).pop(),
+                          child: const Text('Continue')),
+                    ],
+                  ));
         }
       }
       await loginStorage.saveToDisk();
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to