Re: [RFC PATCH 1/1] Add a type for errors
- From
Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
- Date
- Oct 1, 2024, 15:29 UTC
- Message-ID
- <ZvwVZs-HLy0RiP3E@ugly>
- In-Reply-To
- <20240930220352.2461975-2-sandals@crustytoothpaste.net>
On Mon, Sep 30, 2024 at 10:03:52PM +0000, brian m. carlson wrote:
Show 7 quoted lines
>+ 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?
btw, the switch misses breaks.