From Go 1.13:
return fmt.Errorf("unique error message: %w, err)
From third-party pkg/errors package:
import (
// other imports here
"github.com/pkg/errors"
)
return errors.Wrap(err, "unique error message")
Paraphrased explanation (I had a hard time keeping up and don't have enough time to properly replay/annotate):
You add your unique message, then you extend the actual error. Then when something goes wrong you can look at your unique message and it will tell you the "where", and the original message is the "why".
refs GopherCon 2019: Marwan Sulaiman - Handling Go Errors
From Go 1.13:
From third-party
pkg/errorspackage:Paraphrased explanation (I had a hard time keeping up and don't have enough time to properly replay/annotate):
refs GopherCon 2019: Marwan Sulaiman - Handling Go Errors