implement errwrap.Wrapper
diff --git a/error.go b/error.go
index f97c416..47a99e5 100644
--- a/error.go
+++ b/error.go
@@ -1,6 +1,7 @@
package mapstructure
import (
+ "errors"
"fmt"
"sort"
"strings"
@@ -24,6 +25,21 @@
len(e.Errors), strings.Join(points, "\n"))
}
+// WrappedErrors implements the errwrap.Wrapper interface to make this
+// return value more useful with the errwrap and go-multierror libraries.
+func (e *Error) WrappedErrors() []error {
+ if e == nil {
+ return nil
+ }
+
+ result := make([]error, len(e.Errors))
+ for i, e := range e.Errors {
+ result[i] = errors.New(e)
+ }
+
+ return result
+}
+
func appendErrors(errors []string, err error) []string {
switch e := err.(type) {
case *Error: