Skip to content

Commit

Permalink
error/error.go: Improve godocs (no OCI references, etc.)
Browse files Browse the repository at this point in the history
Remove OCI references from the comments, because this is a generic RFC
2119 package and has nothing OCI-specific.  Also document the Error
properties.

Signed-off-by: W. Trevor King <wking@tremily.us>
  • Loading branch information
wking committed Sep 1, 2017
1 parent d268fb2 commit f9152f1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
)

// Level represents the OCI compliance levels
// Level represents the RFC 2119 compliance levels
type Level int

const (
Expand Down Expand Up @@ -43,14 +43,19 @@ const (
Required
)

// Error represents an error with compliance level and OCI reference.
// Error represents an error with compliance level and specification reference.
type Error struct {
Level Level
// Level represents the RFC 2119 compliance level.
Level Level

// Reference is a URL for the violated specification requirement.
Reference string
Err error

// Err holds additional details about the violation.
Err error
}

// ParseLevel takes a string level and returns the OCI compliance level constant.
// ParseLevel takes a string level and returns the RFC 2119 compliance level constant.
func ParseLevel(level string) (Level, error) {
switch strings.ToUpper(level) {
case "MAY":
Expand Down Expand Up @@ -81,7 +86,7 @@ func ParseLevel(level string) (Level, error) {
return l, fmt.Errorf("%q is not a valid compliance level", level)
}

// Error returns the error message with OCI reference
// 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)
}

0 comments on commit f9152f1

Please sign in to comment.