[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-12 Thread anderson . queiroz
Hi Alex, I see your problem is more like merging errors rather than wrapping them. Indeed I don't see any way you could merge 2 errors with the new ` *fmt.Errorf*` I believe what you want is something which could hold 2 errors, like type myError struct { msg string // some additional msg

[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-10 Thread Alex
But when I think about it maybe it is a better practice to only give a leayer2 error message up a singe layer and handle it there. And if needed only propagate a layer1 error message futher up. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-10 Thread Alex
You are right, I think I mixed it up with some other library, I think it was multierr from hashicorp. Have to check that... -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send

[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-10 Thread Agniva De Sarker
Can you show me how is it possible to do with pkg/errors ? It is not immediately apparent to me. The Causer interface is similar to the Unwrap interface and errors.Cause recursively unwraps an error until it finds one which does not implements the causer interface. So just with

[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-09 Thread Alex
Yes, sure. This is always possible. :-) But this is kind of writing your own error wrapper. I was just wondering if this is somehow possible with the new error wrapper like it was with https://github.com/pkg/errors. Am Freitag, 9. August 2019 19:35:42 UTC+2 schrieb Agniva De Sarker: > > I see.

[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-09 Thread Alex
Hi Agniva, the problem is: In the main function is no information that there was an Layer2 error (layer2 error is not included in the error anymore). I don't know how to take the error from layer2 and wrap another error (layer1-error) around it. You can only use the verb "%w" once in a

[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-09 Thread Agniva De Sarker
This is the right way. What is the issue you are facing ? See https://tip.golang.org/pkg/errors/ for more info. You can check for Layer1Error and Layer2Error using the Is function errors.Is(err, Layer1Error) errors.Is(err, Layer2Error) On Friday, 9 August 2019 19:09:24 UTC+5:30, Alex wrote: >

[go-nuts] Re: How to propagate multiple errors using the new fmt.Errorf wrapping

2019-08-09 Thread Alex
Sorry, mixed things up in the code with layer1 and layer2... var ( Layer1Error= errors.New("some error on layer 1") Layer2Error= errors.New("some error on layer 2") ) func main() { err := callLayer1Function() // do something with error } func callLayer1Function() error { err :=