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

2016-09-28 Thread Junio C Hamano
Jeff King writes: > if (!dont_change_ref) { > struct ref_transaction *transaction; > - struct strbuf err = STRBUF_INIT; > - > - transaction = ref_transaction_begin(); > - if (!transaction || > -

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

2016-09-28 Thread Jeff King
On Wed, Sep 28, 2016 at 07:01:38AM +0200, Michael Haggerty wrote: > > - a global for chaining to error, like: > > > >struct error_context print_errors = { > > error, /* actually a wrapper to handle va_list and NULL data */ > > NULL > >}; > > There could

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

2016-09-28 Thread Jeff King
On Tue, Sep 27, 2016 at 06:57:34PM -0400, David Turner wrote: > > 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); > >

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

2016-09-27 Thread Michael Haggerty
On 09/27/2016 09:19 PM, Jeff King wrote: > [...] > I'm going to ramble for a minute, and I don't think it's worth exploring > for this patch series in particular, so feel free to ignore me. > > I think this error concept could be extended fairly elegantly with > something like: > > typedef

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

2016-09-27 Thread David Turner
On Tue, 2016-09-27 at 15:19 -0400, Jeff King wrote: > On Tue, Sep 27, 2016 at 11:19:34AM -0400, David Turner wrote: > > > > typedef void (*err_fn)(const char *, ...); > > > > > > static int decode_tree_entry(struct tree_desc *desc, > > >const char *buf,

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

2016-09-27 Thread Jeff King
On Tue, Sep 27, 2016 at 11:19:34AM -0400, David Turner wrote: > > typedef void (*err_fn)(const char *, ...); > > > > static int decode_tree_entry(struct tree_desc *desc, > >const char *buf, unsigned long size, > >err_fn err) > > {