func (errs *Errors) Push(code ErrorCode, details ...interface{}) {
	if len(details) > 1 {
		panic("please specify zero or one detail items for this error")
	}
	var detail interface{}
	if len(details) > 0 {
		detail = details[0]
	}
	if err, ok := detail.(error); ok {
		detail = err.Error()
	}
	errs.PushErr(Error{
		Code:    code,
		Message: code.Message(),
		Detail:  detail,
	})
}
Push pushes an error on to the error stack, with the optional detail
argument. It is a programming error (ie panic) to push more than one
detail at a time.
package v2
import (
	"fmt"
	"strings"
)
type ErrorCode int
const (
	ErrorCodeUnknown ErrorCode = iota
	ErrorCodeDigestInvalid
	ErrorCodeSizeInvalid
	ErrorCodeNameInvalid
	ErrorCodeTagInvalid
	ErrorCodeNameUnknown
	ErrorCodeManifestUnknown
	ErrorCodeManifestInvalid
	ErrorCodeManifestUnverified
	ErrorCodeBlobUnknown
	ErrorCodeBlobUploadUnknown
)
func ParseErrorCode(s string) ErrorCode {
	desc, ok := idToDescriptors[s]
	if !ok {
		return ErrorCodeUnknown
	}
	return desc.Code
}
func (ec ErrorCode) Descriptor() ErrorDescriptor {
	d, ok := errorCodeToDescriptors[ec]
	if !ok {
		return ErrorCodeUnknown.Descriptor()
	}
	return d
}
func (ec ErrorCode) String() string {
	return ec.Descriptor().Value
}
func (ec ErrorCode) Message() string {
	return ec.Descriptor().Message
}
func (ec ErrorCode) MarshalText() (text []byte, err error) {
	return []byte(ec.String()), nil
}
func (ec *ErrorCode) UnmarshalText(text []byte) error {
	desc, ok := idToDescriptors[string(text)]
	if !ok {
		desc = ErrorCodeUnknown.Descriptor()
	}
	*ec = desc.Code
	return nil
}
type Error struct {
	Code    ErrorCode   `json:"code"`
	Message string      `json:"message,omitempty"`
	Detail  interface{} `json:"detail,omitempty"`
}
func (e Error) Error() string {
	return fmt.Sprintf("%s: %s",
		strings.ToLower(strings.Replace(e.Code.String(), "_", " ", -1)),
		e.Message)
}
type Errors struct {
	Errors []Error `json:"errors,omitempty"`
}