-
Notifications
You must be signed in to change notification settings - Fork 22
/
arg_errors.go
35 lines (28 loc) · 860 Bytes
/
arg_errors.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
package main
import "fmt"
type argErrors struct {
errors []error
warnings []string
}
func newArgErrors() *argErrors {
return &argErrors{
errors: make([]error, 0),
warnings: make([]string, 0),
}
}
func (p *argErrors) flagError(flag string, err error) {
e := fmt.Errorf("parameter %s: %w", flag, err)
p.errors = append(p.errors, e)
}
func (p *argErrors) flagErrorf(flag string, format string, a ...interface{}) {
e := fmt.Errorf("parameter %s: %s", flag, fmt.Sprintf(format, a...))
p.errors = append(p.errors, e)
}
func (p *argErrors) flagWarningf(flag string, format string, a ...interface{}) {
w := fmt.Sprintf("parameter %s: %s", flag, fmt.Sprintf(format, a...))
p.warnings = append(p.warnings, w)
}
func (p *argErrors) warningf(format string, a ...interface{}) {
w := fmt.Sprintf(format, a...)
p.warnings = append(p.warnings, w)
}