-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
513 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// ErrorInvalidKey represents an error caused by an invalid key. | ||
type ErrorInvalidKey struct { | ||
Key string | ||
} | ||
|
||
func (e ErrorInvalidKey) Error() string { | ||
return fmt.Sprintf("invalid key: %s", e.Key) | ||
} | ||
|
||
// ErrorInvalidValue represents an error caused by an invalid value. | ||
type ErrorInvalidValue struct { | ||
Key string | ||
Reason string | ||
} | ||
|
||
func (e ErrorInvalidValue) Error() string { | ||
return fmt.Sprintf("%s: %s", e.Key, e.Reason) | ||
} | ||
|
||
func newErrorInvalidValue(key string, reason string, args ...interface{}) ErrorInvalidValue { | ||
return ErrorInvalidValue{Key: key, Reason: fmt.Sprintf(reason, args...)} | ||
} | ||
|
||
// ErrorParseMulti represents an error caused by a multivalue key. | ||
type ErrorParseMulti []error | ||
|
||
func (es ErrorParseMulti) Error() string { | ||
var ss []string | ||
for _, e := range es { | ||
ss = append(ss, e.Error()) | ||
} | ||
return strings.Join(ss, "\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.