blob: bd26460f194e87c33a31e061bc950e053089dc97 (
plain) (
blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package docopt
import (
"fmt"
)
type errorType int
const (
errorUser errorType = iota
errorLanguage
)
func (e errorType) String() string {
switch e {
case errorUser:
return "errorUser"
case errorLanguage:
return "errorLanguage"
}
return ""
}
// UserError records an error with program arguments.
type UserError struct {
msg string
Usage string
}
func (e UserError) Error() string {
return e.msg
}
func newUserError(msg string, f ...interface{}) error {
return &UserError{fmt.Sprintf(msg, f...), ""}
}
// LanguageError records an error with the doc string.
type LanguageError struct {
msg string
}
func (e LanguageError) Error() string {
return e.msg
}
func newLanguageError(msg string, f ...interface{}) error {
return &LanguageError{fmt.Sprintf(msg, f...)}
}
var newError = fmt.Errorf
|