From: Taylor Blau <me@ttaylorr.com>
To: git@vger.kernel.org
Subject: [TOPIC 03/11] Structured Error Handling
Date: Fri, 20 Sep 2024 10:18:24 -0400 [thread overview]
Message-ID: <Zu2EMKMmNhugAcbY@nand.local> (raw)
In-Reply-To: <Zu2DmS30E0kKug2a@nand.local>
Structured Error Handling
=========================
(moderator: brian, notetaker: jrnieder)
* brian: idea for structured error handling!
* Very little needed - pointer to error string, uint64_t error code,
and ?? (third thing I didn't hear). Return it on the stack. Rust
does this kind of thing all the time.
* Having that structured return value lets a caller decide what to do
with it
- print a message, decide whether to exit or recover, etc.
* Patrick: a few requirements
* want to attach arbitrary metadata to an error (e.g. "I had a
conflict between that file and that file for this revision").
Especially useful on the server side.
* avoid having to parse error messages. Gitaly runs into this. Can
imagine setting an envvar to get json or some other parsable format
instead of human-consumable error messages.
* brian: sounds doable. GitHub also has the same hassle with parsing
error messages.
* Peff: in your proposal, low-level code produces the error struct which
is consumed at a higher level. Sometimes, though, you have many errors
that are related.
* "I couldn't merge these files because I couldn't open this file,
because of this errno".
* One thing we've considered is having a callback to decide what to do
* - print the error, collect into a tree of errors, etc.
* The point is to keep what's happening in the generators of errors
as simple as possible - I have this type of error and maybe some
kind of context strings. That context could be owned by the caller,
the callee can be responsible for copying it, etc. Inversion of
control.
* Patrick: I like the way Go does things, can wrap errors or append
messages, return up the stack until someone handles the error. Why are
we afraid of allocations?
* Peff: What do you do when the allocation fails?
* Patrick: can handle allocation failure by having a special error
that has a statically allocated string.
* Peff: sounds good, getting rid of die() on alloc failure is okay
* brian: Rust panics on out-of-memory anyway
* Peff: there are two different cases - small allocations are "you're
in trouble anyway", big allocation of user-supplied length is
something else
* Carlos: Rust has a "try to allocate memory", relatively new
* Calvin: how do you propagate up the call stack?
* Peff: in my proposal, every function would take an error context
struct, call the callback when there's an error, and keep the
integer function returns. In brian's proposal, we instead return
the struct.
* Emily: Are we comfortable with the amount of churn that generates
in the codebase?
* Patrick: my inspiration is Subversion in that respect. It has nice
error handling in C, they're a role model for me in how to do a
library. It has nice error types that aren't a hassle to use.
* J6t: if you compile in C++ and use exceptions, the problem has been
solved 25 years ago.
* brian: allocating strings for errors and then freeing them is a
hassle in C. Versus Rust where that's handled automatically.
* Emily: so it sounds like this is temporary pain
* Jonathan: I like Patrick's description of requirements. One thing that
would make me more comfortable with the churn is when we get benefit
even from partial conversion
* E.g. could say we get structured error messages for the call sites
that have been converted and not from others. And when I go on a
debugging quest and wish I had a machine-readable structured error
message, I can send a patch to convert more call sites
* Peff: Refs code uses its own strbuf based error handling which is
worse in every way than the options we've been discussing. :) That
can be a good playground to try things out.
* Patrick: +1, seems like a good place to start.
next prev parent reply other threads:[~2024-09-20 14:18 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-20 14:15 Notes from the Git Contributor's Summit, 2024 Taylor Blau
2024-09-20 14:17 ` [TOPIC 01/11] Rust Taylor Blau
2024-09-20 16:20 ` rsbecker
2024-09-23 2:25 ` Sean Allred
2024-09-23 12:17 ` rsbecker
2024-09-24 15:30 ` Phillip Wood
2024-09-24 22:44 ` rsbecker
2024-09-27 9:37 ` Sean Allred
2024-09-27 12:23 ` rsbecker
2024-09-27 17:40 ` rsbecker
2024-09-20 14:17 ` [TOPIC 02/11] Top-level lib/ directory Taylor Blau
2024-09-20 14:18 ` Taylor Blau [this message]
2024-09-20 14:19 ` [TOPIC 04/11] Platform Support Policy Taylor Blau
2024-09-20 14:19 ` [TOPIC 05/11]: SHA 256 / Git 3.0 Taylor Blau
2024-09-20 19:22 ` Junio C Hamano
2024-09-20 14:20 ` [TOPIC 06/11] Git and Software Freedom Conservancy Taylor Blau
2024-09-20 14:20 ` [TOPIC 07/11] New Contributors and Discord Taylor Blau
2024-09-20 22:48 ` Junio C Hamano
2024-09-21 17:02 ` Kousik Sanagavarapu
2024-09-22 19:15 ` Junio C Hamano
2024-09-22 19:44 ` Junio C Hamano
2024-09-23 13:51 ` Konstantin Ryabitsev
2024-09-23 21:31 ` Junio C Hamano
2024-09-24 18:06 ` Konstantin Ryabitsev
2024-09-24 19:15 ` Junio C Hamano
2024-09-24 19:23 ` Konstantin Ryabitsev
2024-09-27 10:08 ` Phillip Wood
2024-09-27 19:22 ` Junio C Hamano
2024-10-01 15:23 ` Phillip Wood
2024-09-20 14:21 ` [TOPIC 08/11] Modern Build Systems Taylor Blau
2024-09-23 2:01 ` Eli Schwartz
2024-09-24 12:13 ` Patrick Steinhardt
2024-09-20 14:22 ` [TOPIC 09/11] Bundle-URI on fetch / resume-able clone Taylor Blau
2024-09-20 14:22 ` [TOPIC 10/11] Project Tracking Taylor Blau
2024-09-20 19:41 ` Junio C Hamano
2024-09-20 19:49 ` Junio C Hamano
2024-09-23 9:15 ` Phillip Wood
2024-09-20 14:23 ` [TOPIC 11/11] git-scm.com state of the site Taylor Blau
-- strict thread matches above, loose matches on Subject: below --
2024-08-24 17:20 [GSoC][PATCH] unit-tests: add tests for oidset.h Ghanshyam Thakkar
2024-08-26 7:02 ` Patrick Steinhardt
2024-08-26 9:31 ` Christian Couder
2024-08-26 15:46 ` Junio C Hamano
2024-09-26 18:28 ` Junio C Hamano
2024-09-26 19:12 ` [PATCH] howto-maintain-git: discarding inactive topics Junio C Hamano
2024-09-27 8:57 ` [GSoC][PATCH] unit-tests: add tests for oidset.h Christian Couder
2024-09-27 18:47 ` Junio C Hamano
2024-09-28 7:02 ` Patrick Steinhardt
2024-09-30 18:48 ` Junio C Hamano
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=Zu2EMKMmNhugAcbY@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
/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).