[pve-devel] [PATCH proxmox-login-manager 1/2] login: show custom alert dialog for password saving errors

Dominik Csapak d.csapak at proxmox.com
Mon Apr 15 12:30:21 CEST 2024


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 at 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





More information about the pve-devel mailing list