forked from jbowes/vice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
59 lines (52 loc) · 2.4 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package vice
import (
"github.com/jbowes/vice/skip"
)
// New returns an error that formats as the given text, and implements the
// behaviour described by the given Vice.
//
// The returned error contains a Frame set to the caller's location and
// implements Formatter to show this information when printed with details.
func New(v Vice, text string) error { return skip.New(skip.Vice(v), 1, text) }
// Errorf returns an error that formats as the format specifier text, and
// implements the behaviour described by the given Vice.
//
// The returned error contains a Frame set to the caller's location and
// implements Formatter to show this information when printed with details.
func Errorf(v Vice, format string, a ...interface{}) error {
return skip.Errorf(skip.Vice(v), 1, format, a...)
}
// Wrap returns an error wrapping err with the supplied text, and a frame
// from the caller's stack. The returned error implements the behaviour
// described by the given Vice. If err is nil, Wrap returns nil.
//
// The error returned implments the Unwrap method, for programatically
// extracting the error chain.
func Wrap(err error, v Vice, text string) error {
return skip.Wrap(err, skip.Vice(v), 1, text)
}
// Wrapf returns an error wrapping err with the supplied format specifier, and
// a frame from the caller's stack. The returned error implements the behaviour
// described by the given Vice. If err is nil, Wrap returns nil.
//
// The error returned implments the Unwrap method, for programatically
// extracting the error chain.
func Wrapf(err error, v Vice, format string, a ...interface{}) error {
return skip.Wrapf(err, skip.Vice(v), 1, format, a...)
}
// Seal returns an error wrapping err with the supplied text, and
// a frame from the caller's stack. The returned error implements the behaviour
// described by the given Vice. If err is nil, Wrap returns nil.
//
// The error returned does not implment the Unwrap method.
func Seal(err error, v Vice, text string) error {
return skip.Seal(err, skip.Vice(v), 1, text)
}
// Sealf returns an error wrapping err with the supplied format specifier, and
// a frame from the caller's stack. The returned error implements the behaviour
// described by the given Vice. If err is nil, Wrap returns nil.
//
// The error returned does not implment the Unwrap method.
func Sealf(err error, v Vice, format string, a ...interface{}) error {
return skip.Sealf(err, skip.Vice(v), 1, format, a...)
}