Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Use xerrors package #106

Open
sergefdrv opened this issue Jul 26, 2019 · 1 comment
Open

Use xerrors package #106

sergefdrv opened this issue Jul 26, 2019 · 1 comment
Labels
good first issue Good for newcomers

Comments

@sergefdrv
Copy link
Contributor

What we could also do is to use "github.com/pkg/errors" package for wrapping error messages in the context of the call stack.

Originally posted by @sergefdrv in #102

@sergefdrv sergefdrv added the good first issue Good for newcomers label Jul 26, 2019
sergefdrv pushed a commit to sergefdrv/minbft that referenced this issue Jan 3, 2020
According to issue hyperledger-labs#106, the code base should eventually switch to use
`pkg/errors` package if favor of built-in `fmt` and `errors` packages.
Switch this package to use `pkg/errors` before doing further changes.

Signed-off-by: Sergey Fedorov <sergey.fedorov@neclab.eu>
@sergefdrv sergefdrv changed the title Use errors package for wrapping error messages Use pkg/errors package for wrapping error messages Jan 3, 2020
@sergefdrv sergefdrv changed the title Use pkg/errors package for wrapping error messages Use pkg/errors package for wrapping errors Jan 3, 2020
sergefdrv pushed a commit to sergefdrv/minbft that referenced this issue Jan 9, 2020
According to issue hyperledger-labs#106, the code base should eventually switch to use
`golang.org/x/xerrors` package if favor of built-in `fmt` and `errors`
packages. Switch this package to use `xerrors` before doing further
changes.

Signed-off-by: Sergey Fedorov <sergey.fedorov@neclab.eu>
@sergefdrv sergefdrv changed the title Use pkg/errors package for wrapping errors Use xerrors package for wrapping errors Jan 9, 2020
@sergefdrv
Copy link
Contributor Author

As discussed in #148 (comment), we should use golang.org/x/xerrors package to wrap errors

xerrors.Errorf("failed to ...: %w", err)

create error values attributed with stack trace

xerrors.New("...")

and the report errors with extra details (stack trace) useful to diagnose errors

logger.Debugf("%+v", err)

@sergefdrv sergefdrv changed the title Use xerrors package for wrapping errors Use xerrors package Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant