Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[errors] Proposal: overlay over pkg/errors to keep context in the error #88

Open
Soulou opened this issue Apr 28, 2019 · 2 comments
Open
Assignees

Comments

@Soulou
Copy link
Member

Soulou commented Apr 28, 2019

We're often giving a lot of context to context.Context, but when an error is returned, most of the case the whole context is lost when an error is returned, we have the stack trace, but not the ID of the models which are concerned.

I'm proposing to add overlay type keeping the context.

errors.CtxWrap(ctx, err, "string") error
errors.CtxWrapf(ctx, err, "format", args...) error
errors.Ctx(err) context.Context
errors.Cause(err) error

The goal is for instance the ability for go-handlers middleware to do something like this.

log := logger.Get(errors.Ctx(err))
log.WithError(errors.Cause(err)).Error("error during request")

What do you think of this?

@johnsudaar
Copy link

Just Y E S !!!!

@Soulou
Copy link
Member Author

Soulou commented Apr 29, 2019

@johnsudaar should we build it over

https://crawshaw.io/blog/xerrors
https://godoc.org/golang.org/x/xerrors

Instead of pkg/errors?

@EtienneM EtienneM removed their assignment Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants