-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
34 lines (27 loc) · 874 Bytes
/
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
package aliaser
import (
"errors"
"strings"
"golang.org/x/tools/go/packages"
)
var (
// ErrNilConfig is returned when the given config is nil.
ErrNilConfig = errors.New("nil config")
// ErrEmptyTarget is returned when the given target is empty.
ErrEmptyTarget = errors.New("empty target")
// ErrEmptyPattern is returned when the given pattern is empty.
ErrEmptyPattern = errors.New("empty pattern")
)
// PackagesErrors is a slice of [packages.Error] as returned by
// [packages.Load] that implements the error interface.
//
// The error message is a concatenation of the messages of the underlying
// errors, separated by a semicolon and a space.
type PackagesErrors []packages.Error
func (e PackagesErrors) Error() string {
msgs := make([]string, 0, len(e))
for _, err := range e {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}