git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>, git@vger.kernel.org
Subject: Re: [RFC PATCH 1/1] Add a type for errors
Date: Wed, 2 Oct 2024 15:01:13 +0100	[thread overview]
Message-ID: <dc1a70b3-9a0f-4c5e-931d-8b3b91335ec7@gmail.com> (raw)
In-Reply-To: <ZvwVZs-HLy0RiP3E@ugly>

Hi Oswald

On 01/10/2024 16:29, Oswald Buddenhagen wrote:
> On Mon, Sep 30, 2024 at 10:03:52PM +0000, brian m. carlson wrote:
>> +        case GIT_ERR_MULTIPLE:
>> +            strbuf_addf(buf, _("multiple errors:\n"));
>> +            for (size_t i = 0; i < me->count; i++) {
>> +                git_error_strbuf(buf, me->errs[i]);
>> +                strbuf_addstr(buf, "\n");
>> +            }
>> +        }
> 
> ah. i was wondering how you'd address this ("this" being non-fatal
> errors piling up), as i'm facing the same problem in a project of mine.
> 
> the problem is that one can either impose a very rigid formatting (as
> you do here), or provide formatting options, which can get arbitrarily
> complex. so i wonder whether one shouldn't pursue a hybrid approach
> instead: singular return values for low-level functions that either work
> or fail fatally, and error callbacks for higher-level functionality?

That's a good point - the rigid formatting is easy to implement but is 
not ideal from the user's point of view. Ideally we'd compose a coherent 
message with the data from the various errors but as you say that's not 
trivial. I wonder if there are any good examples out there that we could 
use as inspiration. The ones I'm aware of (rust's anyhow and svn's 
svn_error_compose) go for a rigid approach. Glib's GError punts the 
problem entirely by forbidding multiple errors.

Best Wishes

Phillip

> btw, the switch misses breaks.
> 
> 


  reply	other threads:[~2024-10-02 14:01 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-30 22:03 [RFC PATCH 0/1] Typed errors brian m. carlson
2024-09-30 22:03 ` [RFC PATCH 1/1] Add a type for errors brian m. carlson
2024-09-30 22:44   ` Junio C Hamano
2024-09-30 23:35     ` brian m. carlson
2024-10-21 12:46       ` Patrick Steinhardt
2024-10-01 15:29   ` Oswald Buddenhagen
2024-10-02 14:01     ` Phillip Wood [this message]
2024-10-01 20:31   ` Emily Shaffer
2024-10-02 21:51     ` brian m. carlson
2024-10-02  9:54   ` Phillip Wood
2024-10-02 22:04     ` brian m. carlson
2024-10-02 22:16       ` Eric Sunshine
2024-10-02 22:24         ` brian m. carlson
2024-10-03  5:14           ` Eric Sunshine
2024-10-03 16:05             ` Junio C Hamano
2024-10-03 22:27               ` Eric Sunshine
2024-10-04  0:15                 ` brian m. carlson
2024-10-04  9:00       ` phillip.wood123
2024-10-04 12:13         ` Richard Kerry
2024-10-03 16:17     ` Emily Shaffer
2024-10-04  9:00       ` phillip.wood123

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=dc1a70b3-9a0f-4c5e-931d-8b3b91335ec7@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=oswald.buddenhagen@gmx.de \
    --cc=phillip.wood@dunelm.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).