git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 0/1] Typed errors

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Sep 30, 2024, 22:03 UTC
Message-ID
<20240930220352.2461975-1-sandals@crustytoothpaste.net>

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
Next: brian m. carlson
Message 1 of 21 in “Typed errors”
  1. 0/1 Typed errorsbrian m. carlson, Sep 30, 2024
  2. 1/1 Add a type for errorsbrian m. carlson, Sep 30, 2024
  3. Junio C HamanoSep 30, 2024
  4. brian m. carlsonSep 30, 2024
  5. Patrick SteinhardtOct 21, 2024
  6. Oswald BuddenhagenOct 1, 2024
  7. Phillip WoodOct 2, 2024
  8. Emily ShafferOct 1, 2024
  9. brian m. carlsonOct 2, 2024
  10. Phillip WoodOct 2, 2024
  11. brian m. carlsonOct 2, 2024
  12. Eric SunshineOct 2, 2024
  13. brian m. carlsonOct 2, 2024
  14. Eric SunshineOct 3, 2024
  15. Junio C HamanoOct 3, 2024
  16. Eric SunshineOct 3, 2024
  17. brian m. carlsonOct 4, 2024
  18. phillip.wood123@gmail.comOct 4, 2024
  19. Richard KerryOct 4, 2024
  20. Emily ShafferOct 3, 2024
  21. phillip.wood123@gmail.comOct 4, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.