public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 widget-toolkit] improve error handling when adding webauthn entries
Date: Tue, 30 Nov 2021 11:04:03 +0100	[thread overview]
Message-ID: <20211130100403.38727-1-w.bumiller@proxmox.com> (raw)

There are cases where we directly throw a string error
(particularly, when navigator.credentials.create() fails,
for example when trying to register the same WA device to
the same user twice), which would end up with the WA window
simply not closing before.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
---
changes to v1:
  * move console.error() call up
  * check for type `object` explicitly
  * use `?.` operator to get the message

 src/window/AddWebauthn.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/window/AddWebauthn.js b/src/window/AddWebauthn.js
index f4a0b10..bef13d1 100644
--- a/src/window/AddWebauthn.js
+++ b/src/window/AddWebauthn.js
@@ -141,8 +141,13 @@ Ext.define('Proxmox.window.AddWebauthn', {
 		    params,
 		});
 	    } catch (response) {
-		let error = response.result.message;
+		let error = response;
 		console.error(error); // for debugging if it's not displayable...
+		if (typeof error === "object") {
+		    // in case it came from an api request:
+		    error = error.result?.message;
+		}
+
 		Ext.Msg.alert(gettext('Error'), error);
 	    }
 
-- 
2.30.2





             reply	other threads:[~2021-11-30 10:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 10:04 Wolfgang Bumiller [this message]
2021-12-02 18:19 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211130100403.38727-1-w.bumiller@proxmox.com \
    --to=w.bumiller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal