mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-12 07:55:07 +08:00

License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com> impl errorf License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com> return a debug error License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
31 lines
634 B
Go
31 lines
634 B
Go
// package debugerror provides a way to augment errors with additional
|
|
// information to allow for easier debugging.
|
|
package debugerror
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/facebookgo/stackerr"
|
|
"github.com/jbenet/go-ipfs/util"
|
|
)
|
|
|
|
func Errorf(format string, a ...interface{}) error {
|
|
return Wrap(fmt.Errorf(format, a...))
|
|
}
|
|
|
|
// New returns an error that contains a stack trace (in debug mode)
|
|
func New(s string) error {
|
|
if util.Debug {
|
|
return stackerr.New(s)
|
|
}
|
|
return errors.New(s)
|
|
}
|
|
|
|
func Wrap(err error) error {
|
|
if util.Debug {
|
|
return stackerr.Wrap(err)
|
|
}
|
|
return err
|
|
}
|