forked from jessevdk/go-flags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
46 lines (35 loc) · 840 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
35
36
37
38
39
40
41
42
43
44
45
46
package flags
// ErrorType represents the type of error.
type ErrorType uint
const (
// Unknown or generic error
ErrUnknown ErrorType = iota
// Expected an argument but got none
ErrExpectedArgument
// Unknown flag
ErrUnknownFlag
// Failed to marshal value
ErrMarshal
// The error contains the builtin help message
ErrHelp
// An argument for a boolean value was specified
ErrNoArgumentForBool
)
// Error represents a parser error. The error returned from Parse is of this
// type. The error contains both a Type and Message.
type Error struct {
// The type of error
Type ErrorType
// The error message
Message string
}
// Get the errors error message.
func (e *Error) Error() string {
return e.Message
}
func newError(tp ErrorType, message string) *Error {
return &Error{
Type: tp,
Message: message,
}
}