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

How to use NewNotFound() properly #65

Open
skreutzberger opened this issue Oct 10, 2023 · 0 comments
Open

How to use NewNotFound() properly #65

skreutzberger opened this issue Oct 10, 2023 · 0 comments

Comments

@skreutzberger
Copy link

skreutzberger commented Oct 10, 2023

Hi,

I am frequently using NewNotFound() and NewBadRequest() in my model logic so that the receiving controller knows about the type of error using an if-statement with errors.Is(err, errors.NotFound) for example.

I just realized now that errors which were wrapped with NewNotFound() somehow have no file, line and function recorded which makes it harder to find the error location.

Here is an example:

err := errors.New("my error")
err = errors.NewNotFound(err, "first context")
println(errors.ErrorStack(err))
       
// returns the following which lacks the file, line and function
first context: my error

Am I using it wrong?

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

1 participant