forked from aws-cloudformation/cloudformation-cli-go-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
45 lines (37 loc) · 1.22 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
package cfnerr
// New base error
func New(code string, message string, origErr error) Error {
var errs []error
if origErr != nil {
errs = append(errs, origErr)
}
return newBaseError(code, message, errs)
}
// NewBatchError groups one or more errors together for processing
func NewBatchError(code string, message string, origErrs []error) BatchedErrors {
return newBaseError(code, message, origErrs)
}
// An Error wraps lower level errors with code, message and an original error.
// The underlying concrete error type may also satisfy other interfaces which
// can be to used to obtain more specific information about the error.
//
// Calling Error() or String() will always include the full information about
// an error based on its underlying type.
type Error interface {
// inherit the base error interface
error
// Returns an error code
Code() string
// Returns the error message
Message() string
// Returns the original error
OrigErr() error
}
// BatchedErrors is a batch of errors which also wraps lower level errors with
// code, message, and original errors. Calling Error() will include all errors
// that occurred in the batch.
type BatchedErrors interface {
error
// Returns all original errors
OrigErrs() []error
}