Re: [go-nuts] Differentiating between reader and writer errors

2018-02-07 Thread Justin Azoff
> > > r, _ = Filter(r, query) > w = LastErrorWrapper(w) > _, err = io.Copy(w, r) > if err != nil and w.LastError != nil { # error writing to output, > abort. > I got halfway through implementing a "LastErrorWrapper" and realized it looked familiar.. that's because it's

Re: [go-nuts] Differentiating between reader and writer errors

2018-02-07 Thread Justin Azoff
On Wednesday, February 7, 2018 at 8:54:12 AM UTC-5, Jakob Borg wrote: > > On 7 Feb 2018, at 14:45, Justin Azoff > wrote: > > > Is there some way to inspect that error to figure out that it was related > to reading from 'gr' and not writing to /dev/null? > > > Two options

Re: [go-nuts] Differentiating between reader and writer errors

2018-02-07 Thread Jakob Borg
On 7 Feb 2018, at 14:45, Justin Azoff > wrote: Is there some way to inspect that error to figure out that it was related to reading from 'gr' and not writing to /dev/null? Two options that come to mind are - handling the copy yourself so

[go-nuts] Differentiating between reader and writer errors

2018-02-06 Thread Tamás Gulácsi
backend.FilterIPs should return differentiable error - whether this is a transient or a permanent error. I'd use github.com/pkg/errors: var ErrTransient = errors.New("transient error") ... func FilterIPs(...) error { if err != nil && err.IsTemporary() { return errors.Wrap(ErrTransient,

[go-nuts] Differentiating between reader and writer errors

2018-02-06 Thread Justin Azoff
Hi! I have a simple service that has an API for searching things like log files. One of the API endpoints returns just the matching documents, while another will try to return the matching records from those documents. Because this output could be quite large (and so that results stream) I