@@ -3,8 +3,42 @@ package migrate
33import (
44 "fmt"
55 nurl "net/url"
6+ "strings"
67)
78
9+ // MultiError holds multiple errors.
10+ //
11+ // Deprecated: Use stdlib's [errors.Join] et al. instead
12+ // This will be removed in the v5 release.
13+ type MultiError struct {
14+ Errs []error
15+ }
16+
17+ // NewMultiError returns an error type holding multiple errors.
18+ //
19+ // Deprecated: Use stdlib's [errors.Join] et al. instead
20+ // This will be removed in the v5 release.
21+ func NewMultiError (errs ... error ) MultiError {
22+ compactErrs := make ([]error , 0 )
23+ for _ , e := range errs {
24+ if e != nil {
25+ compactErrs = append (compactErrs , e )
26+ }
27+ }
28+ return MultiError {compactErrs }
29+ }
30+
31+ // Error implements error. Multiple errors are concatenated with 'and's.
32+ func (m MultiError ) Error () string {
33+ var strs = make ([]string , 0 )
34+ for _ , e := range m .Errs {
35+ if len (e .Error ()) > 0 {
36+ strs = append (strs , e .Error ())
37+ }
38+ }
39+ return strings .Join (strs , " and " )
40+ }
41+
842// suint safely converts int to uint
943// see https://goo.gl/wEcqof
1044// see https://goo.gl/pai7Dr
0 commit comments