aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/go-multierror/multierror.go
diff options
context:
space:
mode:
authorJake Champlin <jake.champlin.27@gmail.com>2017-06-06 12:40:07 -0400
committerJake Champlin <jake.champlin.27@gmail.com>2017-06-06 12:40:07 -0400
commitbae9f6d2fd5eb5bc80929bd393932b23f14d7c93 (patch)
treeca9ab12a7d78b1fc27a8f734729081357ce6d252 /vendor/github.com/hashicorp/go-multierror/multierror.go
parent254c495b6bebab3fb72a243c4bce858d79e6ee99 (diff)
downloadterraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.gz
terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.tar.zst
terraform-provider-statuscake-bae9f6d2fd5eb5bc80929bd393932b23f14d7c93.zip
Initial transfer of provider code
Diffstat (limited to 'vendor/github.com/hashicorp/go-multierror/multierror.go')
-rw-r--r--vendor/github.com/hashicorp/go-multierror/multierror.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/go-multierror/multierror.go b/vendor/github.com/hashicorp/go-multierror/multierror.go
new file mode 100644
index 0000000..2ea0827
--- /dev/null
+++ b/vendor/github.com/hashicorp/go-multierror/multierror.go
@@ -0,0 +1,51 @@
1package multierror
2
3import (
4 "fmt"
5)
6
7// Error is an error type to track multiple errors. This is used to
8// accumulate errors in cases and return them as a single "error".
9type Error struct {
10 Errors []error
11 ErrorFormat ErrorFormatFunc
12}
13
14func (e *Error) Error() string {
15 fn := e.ErrorFormat
16 if fn == nil {
17 fn = ListFormatFunc
18 }
19
20 return fn(e.Errors)
21}
22
23// ErrorOrNil returns an error interface if this Error represents
24// a list of errors, or returns nil if the list of errors is empty. This
25// function is useful at the end of accumulation to make sure that the value
26// returned represents the existence of errors.
27func (e *Error) ErrorOrNil() error {
28 if e == nil {
29 return nil
30 }
31 if len(e.Errors) == 0 {
32 return nil
33 }
34
35 return e
36}
37
38func (e *Error) GoString() string {
39 return fmt.Sprintf("*%#v", *e)
40}
41
42// WrappedErrors returns the list of errors that this Error is wrapping.
43// It is an implementatin of the errwrap.Wrapper interface so that
44// multierror.Error can be used with that library.
45//
46// This method is not safe to be called concurrently and is no different
47// than accessing the Errors field directly. It is implementd only to
48// satisfy the errwrap.Wrapper interface.
49func (e *Error) WrappedErrors() []error {
50 return e.Errors
51}