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

Re: thoughts on error passing, was Re: [PATCH 2/2] fsck: handle bad trees like other errors

From
Jeff King <peff@peff.net>
Date
Sep 28, 2016, 06:54 UTC
Message-ID
<20160928065451.klz4okmag3ksz3gu@sigill.intra.peff.net>
In-Reply-To
<1475017054.13103.3.camel@frank>
On Tue, Sep 27, 2016 at 06:57:34PM -0400, David Turner wrote:
Show 26 quoted lines
> >   int report_error(struct error_context *err, const char *fmt, ...)
> >   {
> >         if (err->fn) {
> >                 va_list ap;
> >                 va_start(ap, fmt);
> >                 err->fn(err->data, fmt, ap);
> >                 va_end(ap);
> >         }
> >         return -1;
> >   }
> > 
> > Then low-level functions just take a context and do:
> > 
> >   return report_error(&err, "some error: %s", foo);
> > 
> > And then the callers would pick one of a few generic error contexts:
> > 
> >   - passing NULL silences the errors
> 
> Overall, +1.
> 
> I guess I would rather have a sentinel value for silencing errors,
> because I'm worried that someone might read NULL as "don't handle the
> errors, just die".  Of course, code review would hopefully catch this,
> but even so, it would be easier to read foo(x, y, silence_errors) than
> foo(x, y, null).

Yeah, I waffled on that. If you look carefully, you'll note that the report_error() I showed above would actually require such a "{ NULL, NULL }" global.

I don't plan to make any patches immediately for this, but I'll let it percolate and consider whether it makes sense to try out for a future series.

-Peff
Previous: David TurnerNext: Michael Haggerty
Message 14 of 22 in “tree-walk improvements”
  1. 0/2 tree-walk improvementsDavid Turner, Sep 26, 2016
  2. 1/2 tree-walk: be more specific about corrupt tree errorsDavid Turner, Sep 26, 2016
  3. Jeff KingSep 27, 2016
  4. Junio C HamanoSep 27, 2016
  5. David TurnerSep 27, 2016
  6. 2/2 fsck: handle bad trees like other errorsDavid Turner, Sep 26, 2016
  7. Junio C HamanoSep 26, 2016
  8. Junio C HamanoSep 26, 2016
  9. Junio C HamanoSep 26, 2016
  10. Jeff KingSep 27, 2016
  11. David TurnerSep 27, 2016
  12. thoughts on error passing, was Re: [PATCH 2/2] fsck: handle bad trees like other errorsJeff King, Sep 27, 2016
  13. David TurnerSep 27, 2016
  14. Jeff KingSep 28, 2016
  15. Michael HaggertySep 28, 2016
  16. Jeff KingSep 28, 2016
  17. Junio C HamanoSep 28, 2016
  18. Stefan BellerSep 26, 2016
  19. Junio C HamanoSep 26, 2016
  20. David TurnerSep 26, 2016
  21. Junio C HamanoSep 27, 2016
  22. Junio C HamanoSep 26, 2016

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.