summaryrefslogtreecommitdiff
path: root/vendor/github.com/opencontainers/runtime-tools/error/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/opencontainers/runtime-tools/error/error.go')
-rw-r--r--vendor/github.com/opencontainers/runtime-tools/error/error.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/github.com/opencontainers/runtime-tools/error/error.go b/vendor/github.com/opencontainers/runtime-tools/error/error.go
index f5a90800e..f7eac6639 100644
--- a/vendor/github.com/opencontainers/runtime-tools/error/error.go
+++ b/vendor/github.com/opencontainers/runtime-tools/error/error.go
@@ -86,6 +86,36 @@ func ParseLevel(level string) (Level, error) {
return l, fmt.Errorf("%q is not a valid compliance level", level)
}
+// String takes a RFC 2119 compliance level constant and returns a string representation.
+func (level Level) String() string {
+ switch level {
+ case May:
+ return "MAY"
+ case Optional:
+ return "OPTIONAL"
+ case Should:
+ return "SHOULD"
+ case ShouldNot:
+ return "SHOULD NOT"
+ case Recommended:
+ return "RECOMMENDED"
+ case NotRecommended:
+ return "NOT RECOMMENDED"
+ case Must:
+ return "MUST"
+ case MustNot:
+ return "MUST NOT"
+ case Shall:
+ return "SHALL"
+ case ShallNot:
+ return "SHALL NOT"
+ case Required:
+ return "REQUIRED"
+ }
+
+ panic(fmt.Sprintf("%d is not a valid compliance level", level))
+}
+
// Error returns the error message with specification reference.
func (err *Error) Error() string {
return fmt.Sprintf("%s\nRefer to: %s", err.Err.Error(), err.Reference)