pkg / errors

Simple error handling primitives
https://godoc.org/github.com/pkg/errors
BSD 2-Clause "Simplified" License
8.18k stars 692 forks source link

QUESTION: How does one incorporate this with behaviors? #163

Closed ntucker closed 6 years ago

ntucker commented 6 years ago

In https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully there is talk about having interfaces for certain types of checks, but how does one actually build a new error with these interfaces and also use the cool error types provided here?

One might think composing the types would work, but this package doesn't make its types public.

davecheney commented 6 years ago

The intention is you start with your own error type which implements the behaviour you want to assert for, then use Wrap or With to annotate it during the error path, at the point you want to test for the original behaviour, use cause to undo all those layers of annotations and recover the original error.

On 19 Jul 2018, at 07:18, Nathaniel Tucker notifications@github.com wrote:

In https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully there is talk about having interfaces for certain types of checks, but how does one actually build a new error with these interfaces and also use the cool error types provided here?

One might think composing the types would work, but this package doesn't make its types public.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ntucker commented 6 years ago

(In case it wasn't clear from the close: thanks for the prompt and clear explanation!)