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 := callLayer2Function() // how to not lose layer2 error but also append a new layer1 error ? // this does not work, since you fully lose layer1 error // with pkg/err return fmt.Errorf("some specific layer 1 error message: %w", Layer1Error) } func callLayer2Function() error { // wrap an error of Layer2 here return fmt.Errorf("some specific layer2 error message: %w", Layer2Error) } -- 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 an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/13d370de-1ea0-48aa-96df-273b5cdb4e53%40googlegroups.com.