summaryrefslogtreecommitdiff
path: root/parsefuncs.go
diff options
context:
space:
mode:
authorEthel Morgan <eth@ethulhu.co.uk>2020-07-07 15:35:24 +0100
committerEthel Morgan <eth@ethulhu.co.uk>2020-07-07 15:35:24 +0100
commite871aa3046a981eccf9b2a042b7d2ced9f109355 (patch)
tree0edcf2d5ad417f20c26a4462b05f59c6d6cf16e6 /parsefuncs.go
parentaa380da6a61f9b29ee263d95d17a2953a0528b28 (diff)
add ErrRequired canonical error for "flag is required"HEADv0.0.2latest
Diffstat (limited to '')
-rw-r--r--parsefuncs.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/parsefuncs.go b/parsefuncs.go
index 0263a5a..793e732 100644
--- a/parsefuncs.go
+++ b/parsefuncs.go
@@ -11,9 +11,14 @@ import (
"strings"
)
+var (
+ // ErrRequired provides a canonical "you must set this flag" error message.
+ ErrRequired = errors.New("must not be empty")
+)
+
func RequiredString(raw string) (interface{}, error) {
if raw == "" {
- return nil, errors.New("must not be empty")
+ return nil, ErrRequired
}
return raw, nil
}