From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH backup 4/4] api: use if-let pattern for error-only handling
Date: Tue, 13 Feb 2024 11:26:38 +0100 [thread overview]
Message-ID: <1707819653.575de1h3gk.astroid@yuna.none> (raw)
In-Reply-To: <20240213095320.186188-4-m.sandoval@proxmox.com>
On February 13, 2024 10:53 am, Maximiliano Sandoval wrote:
> It is more readable than using match. We also inline variables in
> eprintln!.
what about the exact same pattern directly above it? there's like 10
more places to look at based on simple grepping..
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> src/api2/access/user.rs | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs
> index 118838ce..035c8a57 100644
> --- a/src/api2/access/user.rs
> +++ b/src/api2/access/user.rs
> @@ -391,18 +391,12 @@ pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error>
> }
> }
>
> - match crate::config::tfa::read().and_then(|mut cfg| {
> + if let Err(err) = crate::config::tfa::read().and_then(|mut cfg| {
> let _: proxmox_tfa::api::NeedsSaving =
> cfg.remove_user(&crate::config::tfa::UserAccess, userid.as_str())?;
> crate::config::tfa::write(&cfg)
> }) {
> - Ok(()) => (),
> - Err(err) => {
> - eprintln!(
> - "error updating TFA config after deleting user {:?}: {}",
> - userid, err
> - );
> - }
> + eprintln!("error updating TFA config after deleting user {userid:?} {err}",);
> }
>
> Ok(())
> --
> 2.39.2
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
next prev parent reply other threads:[~2024-02-13 10:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 9:53 [pbs-devel] [PATCH backup 1/4] disks: remove useless conversion to the same type Maximiliano Sandoval
2024-02-13 9:53 ` [pbs-devel] [PATCH backup 2/4] backup-proxy: avoid block in if condition Maximiliano Sandoval
2024-02-13 10:29 ` Fabian Grünbichler
2024-02-13 9:53 ` [pbs-devel] [PATCH backup 3/4] report: inline errors in writeln! Maximiliano Sandoval
2024-02-13 9:53 ` [pbs-devel] [PATCH backup 4/4] api: use if-let pattern for error-only handling Maximiliano Sandoval
2024-02-13 10:26 ` Fabian Grünbichler [this message]
2024-02-13 10:30 ` [pbs-devel] partially-applied: [PATCH backup 1/4] disks: remove useless conversion to the same type Fabian Grünbichler
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=1707819653.575de1h3gk.astroid@yuna.none \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-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