func NewError(code Code, err error, version string) error {
	rfcError, err2 := NewRFCError(code, err, version)
	if err2 != nil {
		return err2
	}
	return &Error{
		Err:  *rfcError,
		Code: code,
	}
}
NewError creates an Error referencing a spec violation.  The error
can be cast to an *Error for extracting structured information
about the level of the violation and a reference to the violated
spec condition.

A version string (for the version of the spec that was violated)
must be set to get a working URL.
package specerror
import (
	"fmt"
	"github.com/hashicorp/go-multierror"
	rfc2119 "github.com/opencontainers/runtime-tools/error"
)
const referenceTemplate = "https://github.com/opencontainers/runtime-spec/blob/v%s/%s"
type Code int64
const (
	NonError Code = 0x1a001 + iota
	NonRFCError
)
type errorTemplate struct {
	Level     rfc2119.Level
	Reference func(version string) (reference string, err error)
}
type Error struct {
	Err rfc2119.Error
	Code Code
}
type LevelErrors struct {
	Warnings []*Error
	Error *multierror.Error
}
var ociErrors = map[Code]errorTemplate{}
func register(code Code, level rfc2119.Level, ref func(versiong string) (string, error)) {
	if _, ok := ociErrors[code]; ok {
		panic(fmt.Sprintf("should not regist a same code twice: %v", code))
	}
	ociErrors[code] = errorTemplate{Level: level, Reference: ref}
}
func (err *Error) Error() string {
	return err.Err.Error()
}
func NewRFCError(code Code, err error, version string) (*rfc2119.Error, error) {
	template := ociErrors[code]
	reference, err2 := template.Reference(version)
	if err2 != nil {
		return nil, err2
	}
	return &rfc2119.Error{
		Level:     template.Level,
		Reference: reference,
		Err:       err,
	}, nil
}
func NewRFCErrorOrPanic(code Code, err error, version string) *rfc2119.Error {
	rfcError, err2 := NewRFCError(code, err, version)
	if err2 != nil {
		panic(err2.Error())
	}
	return rfcError
}