public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Wolfgang Bumiller <w.bumiller@proxmox.com>
Subject: Re: [pve-devel] [PATCH widget-toolkit] improve error handling when adding webauthn entries
Date: Thu, 18 Nov 2021 08:24:54 +0100	[thread overview]
Message-ID: <2cfafc98-6bcd-58ed-7797-f2a07f235d6d@proxmox.com> (raw)
In-Reply-To: <20211117083510.51050-1-w.bumiller@proxmox.com>

On 17.11.21 09:35, Wolfgang Bumiller wrote:
> 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>
> ---
>  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..77d0914 100644
> --- a/src/window/AddWebauthn.js
> +++ b/src/window/AddWebauthn.js
> @@ -141,7 +141,12 @@ Ext.define('Proxmox.window.AddWebauthn', {
>  		    params,
>  		});
>  	    } catch (response) {
> -		let error = response.result.message;
> +		let error = response;
> +		if (typeof error !== "string") {

why not

if (typeof error === "object") {

as just because it isn't a string it doesn't need to be a valid object..

> +		    // in case it came from an api request:
> +		    error = error.result.message;

maybe use the optional chaining operator here to make the error path a bit
more robust.

> +		}
> +
>  		console.error(error); // for debugging if it's not displayable...

should above be moved above the if then? To ensure that as much info as possible
is available from the error?

>  		Ext.Msg.alert(gettext('Error'), error);
>  	    }
> 





      reply	other threads:[~2021-11-18  7:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17  8:35 Wolfgang Bumiller
2021-11-18  7:24 ` Thomas Lamprecht [this message]

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=2cfafc98-6bcd-58ed-7797-f2a07f235d6d@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=w.bumiller@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