]> git.proxmox.com Git - flutter/proxmox_login_manager.git/commitdiff
login: show custom alert dialog for password saving errors
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 15 Apr 2024 10:30:21 +0000 (12:30 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 16 Apr 2024 14:31:45 +0000 (16:31 +0200)
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.csapak@proxmox.com>
lib/proxmox_login_form.dart

index e31d0c0dddd98838544c29c0137af97281a811d5..9c25126bb6db7540e62dbccd9c3efe403f8753bb 100644 (file)
@@ -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();