errors

package
v0.0.0-...-969384c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// NotFoundCode is code for the error of no object found
	NotFoundCode = "NOT_FOUND"
	// ConflictCode ...
	ConflictCode = "CONFLICT"
	// UnAuthorizedCode ...
	UnAuthorizedCode = "UNAUTHORIZED"
	// BadRequestCode ...
	BadRequestCode = "BAD_REQUEST"
	// ForbiddenCode ...
	ForbiddenCode = "FORBIDDEN"
	// MethodNotAllowedCode ...
	MethodNotAllowedCode = "METHOD_NOT_ALLOWED"
	// RateLimitCode
	RateLimitCode = "TOO_MANY_REQUEST"
	// PreconditionCode ...
	PreconditionCode = "PRECONDITION"
	// GeneralCode ...
	GeneralCode = "UNKNOWN"
	// ChallengesUnsupportedCode ...
	ChallengesUnsupportedCode = "ChallengesUnsupportedCode"
	// DENIED it's used by middleware(readonly, vul and content trust) and returned to docker client to index the request is denied.
	DENIED = "DENIED"
	// PROJECTPOLICYVIOLATION ...
	PROJECTPOLICYVIOLATION = "PROJECTPOLICYVIOLATION"
	// ViolateForeignKeyConstraintCode is the error code for violating foreign key constraint error
	ViolateForeignKeyConstraintCode = "VIOLATE_FOREIGN_KEY_CONSTRAINT"
	// DIGESTINVALID ...
	DIGESTINVALID = "DIGEST_INVALID"
	// MANIFESTINVALID ...
	MANIFESTINVALID = "MANIFEST_INVALID"
	// UNSUPPORTED is for digest UNSUPPORTED error
	UNSUPPORTED = "UNSUPPORTED"
)

Variables

View Source
var (
	// As alias function of `errors.As`
	As = errors.As
	// Is alias function of `errors.Is`
	Is = errors.Is
)

Functions

func Cause

func Cause(err error) error

Cause gets the root error

func ErrCode

func ErrCode(err error) string

ErrCode returns code of err

func IsChallengesUnsupportedErr

func IsChallengesUnsupportedErr(err error) bool

func IsConflictErr

func IsConflictErr(err error) bool

IsConflictErr checks whether the err chain contains conflict error

func IsErr

func IsErr(err error, code string) bool

IsErr checks whether the err chain contains error matches the code

func IsNotFoundErr

func IsNotFoundErr(err error) bool

IsNotFoundErr returns true when the error is NotFoundError

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError checks whether the err chains contains rate limit error

Types

type Error

type Error struct {
	Cause   error  `json:"-"`
	Code    string `json:"code"`
	Message string `json:"message"`
	Stack   *stack `json:"-"`
}

Error ...

func BadRequestError

func BadRequestError(err error) *Error

BadRequestError is error for the case of bad request

func ConflictError

func ConflictError(err error) *Error

ConflictError is error for the case of object conflict

func DeniedError

func DeniedError(err error) *Error

DeniedError is error for the case of denied

func Errorf

func Errorf(format string, args ...interface{}) *Error

Errorf ...

func ForbiddenError

func ForbiddenError(err error) *Error

ForbiddenError is error for the case of forbidden

func MethodNotAllowedError

func MethodNotAllowedError(err error) *Error

MethodNotAllowedError is error for the case of forbidden

func New

func New(in interface{}) *Error

New ...

func NotFoundError

func NotFoundError(err error) *Error

NotFoundError is error for the case of object not found

func PreconditionFailedError

func PreconditionFailedError(err error) *Error

PreconditionFailedError is error for the case of precondition failed

func UnauthorizedError

func UnauthorizedError(err error) *Error

UnauthorizedError is error for the case of unauthorized accessing

func UnknownError

func UnknownError(err error) *Error

UnknownError ...

func Wrap

func Wrap(err error, message string) *Error

Wrap ...

func Wrapf

func Wrapf(err error, format string, args ...interface{}) *Error

Wrapf ...

func (*Error) Error

func (e *Error) Error() string

Error returns a human readable error, error.Error() will not contains the track information. Needs it? just call error.StackTrace() Code will not be in the error output.

func (*Error) MarshalJSON

func (e *Error) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Error) StackTrace

func (e *Error) StackTrace() string

StackTrace ...

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap ...

func (*Error) WithCause

func (e *Error) WithCause(err error) *Error

WithCause ...

func (*Error) WithCode

func (e *Error) WithCode(code string) *Error

WithCode ...

func (*Error) WithMessage

func (e *Error) WithMessage(message string) *Error

WithMessage ...

func (*Error) WithMessagef

func (e *Error) WithMessagef(format string, v ...interface{}) *Error

WithMessagef ...

type Errors

type Errors []error

Errors ...

func NewErrs

func NewErrs(err error) Errors

NewErrs ...

func (Errors) Error

func (errs Errors) Error() string

Error converts slice of error

func (Errors) Len

func (errs Errors) Len() int

Len returns the current number of errors.

type StackFrames

type StackFrames []runtime.Frame

StackFrames ... ToDo we can define an Harbor frame to customize trace message, but it depends on requirement

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL