errors

package
v2.14.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAlreadyExists

func NewAlreadyExists(kind, name string) error

NewAlreadyExists creates a HTTP 409 already exists error

func NewBadRequest

func NewBadRequest(msg string, options ...interface{}) error

NewBadRequest creates a HTTP 400 error.

func NewConflict

func NewConflict(kind, dc, name string) error

NewConflict creates a HTTP 409 error for a kind in a datacenter.

func NewNotAuthorized

func NewNotAuthorized() error

NewNotAuthorized creates a HTTP 401 error.

func NewNotFound

func NewNotFound(kind, name string) error

NewNotFound creates a HTTP 404 error for a kind.

func NewNotImplemented

func NewNotImplemented() error

NewNotImplemented creates a HTTP 501 'not implemented' error.

func NewWrongRequest

func NewWrongRequest(got, want interface{}) error

NewWrongRequest creates a HTTP 400 error, if we got a wrong request type.

Types

type Aggregate

type Aggregate interface {
	error
	Errors() []error
}

Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning.

func NewAggregate

func NewAggregate(errlist []error) Aggregate

NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface. If the slice is empty, this returns nil. It will check if any of the element of input error list is nil, to avoid nil pointer panic when call Error().

type HTTPError

type HTTPError struct {
	// contains filtered or unexported fields
}

HTTPError represents an HTTP server error.

func New

func New(code int, msg string) HTTPError

New creates a brand new HTTPError object

func NewWithDetails

func NewWithDetails(code int, msg string, details []string) HTTPError

NewWithDetails creates a brand new HTTPError object

func (HTTPError) Details

func (err HTTPError) Details() []string

Details returns additional message about the errors

func (HTTPError) Error

func (err HTTPError) Error() string

Error implements the error interface.

func (HTTPError) StatusCode

func (err HTTPError) StatusCode() int

StatusCode returns the status code for the error

Jump to

Keyboard shortcuts

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