1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-12 07:55:07 +08:00
Files
kubo/util/debugerror/debugerror.go
Brian Tiger Chow eb5bb1daa8 feat(debugerror)
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>
2014-11-14 17:04:48 -08:00

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
}