...
1
2
3
4
5 package errors
6
7 import (
8 "fmt"
9
10 goerrors "github.com/go-errors/errors"
11 )
12
13
14 func Wrap(err interface{}) error {
15 if err == nil {
16 return nil
17 }
18 return goerrors.Wrap(err, 1)
19 }
20
21
22 func WrapPrefixf(err interface{}, msg string, args ...interface{}) error {
23 if err == nil {
24 return nil
25 }
26 return goerrors.WrapPrefix(err, fmt.Sprintf(msg, args...), 1)
27 }
28
29
30 func Errorf(msg string, args ...interface{}) error {
31 return goerrors.Wrap(fmt.Errorf(msg, args...), 1)
32 }
33
34
35 func As(err error, target interface{}) bool {
36 return goerrors.As(err, target)
37 }
38
39
40 func Is(err error, target error) bool {
41 return goerrors.Is(err, target)
42 }
43
44
45 func GetStack(err error) string {
46 if e, ok := err.(*goerrors.Error); ok {
47 return string(e.Stack())
48 }
49 return ""
50 }
51
View as plain text