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

Re: Proposal/Discussion: Turning parts of Git into libraries

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 24, 2023, 22:59 UTC
Message-ID
<xmqqbkliwtyy.fsf@gitster.g>
In-Reply-To
<CAJoAoZknYizS4peYgR4Zy5KUMEpFUbj5eREZoC_K5vUDXnAhng@mail.gmail.com>
Emily Shaffer <nasamuffin@google.com> writes:
Show 6 quoted lines
> Is there a reason not to use this kind of struct and provide
> library-specific error code enums, though, I wonder? You're right that
> parsing the error string is really bad for the caller, for anything
> besides just logging it. But it seems somewhat reasonable to expect
> that any call from config library returning an integer error code is
> referring to enum config_errors...

In addition to what Peff already said, I think the harder part of it is to parametralize the errors in a machine readable way. A part of a library may say (with an enum) that it is returning "Ref cannot be read" error, with a parameter that says "The ref that caused this error was 'refs/heads/next'" which makes "Ref cannot be read" error has one parameter. "Ref cannot be renamed" may have two (old and new name). Other errors from some library functions may not even be of type "string".

Coming up with the enums to cover the error conditions (which Peff covered well) is already a lot of work. Making sure each of them take sufficient parameters to describe the error usefully adds more on top. And the code to pass these variable number of parameters of variable types would be, eh, fun---it would be error prone without compiler help.

Previous: Jeff KingNext: rsbecker@nexbridge.com
Message 9 of 37 in “Proposal/Discussion: Turning parts of Git into libraries”
  1. Emily ShafferFeb 17, 2023
  2. brian m. carlsonFeb 17, 2023
  3. Emily ShafferFeb 17, 2023
  4. brian m. carlsonFeb 17, 2023
  5. Emily ShafferFeb 17, 2023
  6. Jeff KingFeb 22, 2023
  7. Emily ShafferFeb 24, 2023
  8. Jeff KingFeb 24, 2023
  9. Junio C HamanoFeb 24, 2023
  10. rsbecker@nexbridge.comFeb 17, 2023
  11. brian m. carlsonFeb 17, 2023
  12. Junio C HamanoFeb 17, 2023
  13. demerphqFeb 18, 2023
  14. Phillip WoodFeb 18, 2023
  15. Felipe ContrerasMar 23, 2023
  16. rsbecker@nexbridge.comMar 23, 2023
  17. Felipe ContrerasMar 23, 2023
  18. rsbecker@nexbridge.comMar 23, 2023
  19. Felipe ContrerasMar 23, 2023
  20. rsbecker@nexbridge.comMar 24, 2023
  21. Felipe ContrerasMar 24, 2023
  22. rsbecker@nexbridge.comMar 24, 2023
  23. Felipe ContrerasMar 24, 2023
  24. Emily ShafferFeb 21, 2023
  25. Junio C HamanoFeb 22, 2023
  26. Elijah NewrenFeb 18, 2023
  27. Emily ShafferFeb 21, 2023
  28. Elijah NewrenFeb 22, 2023
  29. Jeff KingFeb 22, 2023
  30. Taylor BlauFeb 21, 2023
  31. Emily ShafferFeb 21, 2023
  32. Victoria DyeFeb 22, 2023
  33. Jonathan TanFeb 25, 2023
  34. Derrick StoleeFeb 22, 2023
  35. Emily ShafferFeb 24, 2023
  36. Felipe ContrerasMar 23, 2023
  37. rsbecker@nexbridge.comMar 23, 2023

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.