errors

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As gets the first error in the chain that matches the target

func Cause

func Cause(err error) error

Cause gets the original error

func GetStackTraceForError

func GetStackTraceForError(err error) errors.StackTrace

GetStackTraceForError returns the HTTP status for a particular error.

func HTTPCodeForError

func HTTPCodeForError(err error) int

HTTPCodeForError returns the HTTP status for a particular error.

func Is

func Is(err, target error) bool

Is for seeing if an error includes the target error

func Unwrap

func Unwrap(err error) error

Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error. Otherwise, Unwrap returns nil.

Types

type GetStackTrace

type GetStackTrace interface {
	StackTrace() errors.StackTrace
}

GetStackTrace returns the API Code

type HTTPCode

type HTTPCode interface {
	HTTPCode() int
}

HTTPCode returns the API Code

type MultiError

type MultiError struct {
	Message string
	Errors  []error
}

MultiError is an Error type that wraps multiple errors. This can be a useful way to combine errors in a method where you want to allow process to continue through multiple failed steps.

func NewMultiError

func NewMultiError(msg string, errs []error) *MultiError

NewMultiError is a list of errors

func (MultiError) Error

func (e MultiError) Error() string

Error returns the error message to satisfy the error interface

func (MultiError) Is

func (e MultiError) Is(err error) bool

Is to satisfy the error comparison interface

type StatusError

type StatusError struct {
	Details detailError `json:"error"`
	// contains filtered or unexported fields
}

StatusError is the custom error type we are using. Should satisfy errors interface

func NewAdminRoleNotAssumable

func NewAdminRoleNotAssumable(role string, err error) *StatusError

NewAdminRoleNotAssumable returns a new error representing an admin role not being assumable

func NewAlreadyExists

func NewAlreadyExists(group string, name string) *StatusError

NewAlreadyExists returns a new error representing an already exists error

func NewBadRequest

func NewBadRequest(m string) *StatusError

NewBadRequest returns a new error representing a bad request

func NewConflict

func NewConflict(group string, name string, err error) *StatusError

NewConflict returns a new error for representing Conflicts

func NewGenericStatusError

func NewGenericStatusError(statusCode int, err error) *StatusError

NewGenericStatusError creates an error from a generic set of information

func NewInternalServer

func NewInternalServer(m string, err error) *StatusError

NewInternalServer returns an error for Internal Server Errors

func NewNotFound

func NewNotFound(group string, name string) *StatusError

NewNotFound returns an a NotFound error with standard messaging

func NewServiceUnavailable

func NewServiceUnavailable(m string) *StatusError

NewServiceUnavailable returns a new error representing service unavailable

func NewUnathorizedError

func NewUnathorizedError(m string) *StatusError

NewUnathorizedError returns an a NewUnathorizedError error with standard messaging

func NewValidation

func NewValidation(group string, err error) *StatusError

NewValidation creates a validation error

func (StatusError) Error

func (e StatusError) Error() string

func (StatusError) Format

func (e StatusError) Format(s fmt.State, verb rune)

Format for the standard format library

func (StatusError) HTTPCode

func (e StatusError) HTTPCode() int

HTTPCode returns the http code

func (StatusError) Is

func (e StatusError) Is(err error) bool

Is checks to see if the errors match

func (StatusError) OriginalError

func (e StatusError) OriginalError() error

OriginalError provides the underlying error

func (StatusError) StackTrace

func (e StatusError) StackTrace() errors.StackTrace

StackTrace returns the frames for a stack trace

Jump to

Keyboard shortcuts

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