mbox series

[RFC,0/1] Typed errors

Message ID 20240930220352.2461975-1-sandals@crustytoothpaste.net (mailing list archive)
Headers show
Series Typed errors | expand

Message

brian m. carlson Sept. 30, 2024, 10:03 p.m. UTC
We've discussed, as part of the libification effors and at the most
recent Git Merge conference, the possibility of typed errors in Git.
This would be useful because it allows users of our library to
understand why an error occurred and what to do about it in addition to
knowing just that one occurred.

In addition, as someone who has done a lot of scripting of Git in my
professional life, I've noticed we have a plethora of different messages
for the same problem.  As a consequence, it's very difficult to
automatically map all errors where an object is absent into a distinct
error type, which makes automation hard.  It would be easier to work
with Git as a scripting aid if all error of the same type produced a
uniform message that could be easily parsed.

I had indicated that I have a design for this, which I've improved with
feedback from the contributor summit.  This is, therefore, an RFC that
doesn't wire things up in any way, but is suitable for discussion about
the approach and design. It may be that we eventually adopt this
approach, or we may discard it in favour of another, and either way,
that's fine.

I will say that the fact that we have a pointer here is useful, but it
means that freeing memory is necessary.  That's inconvenient, but if we
choose to adopt Rust on a larger scale, it should be much easier to
handle by simply using a `Drop` implementation to free the memory.

brian m. carlson (1):
  Add a type for errors

 Makefile |   1 +
 error.c  |  43 ++++++++++++++
 error.h  | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 212 insertions(+)
 create mode 100644 error.c
 create mode 100644 error.h