errors

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewExistsSVCErrGen is a generator function for building ExistsSVCErrs with the specified
	// resource supplied to all exists errs created.
	NewExistsSVCErrGen = func(resource string) ExistsErrGenFn {
		return func(op, msg string) *ExistsSVCErr {
			return NewExistsSVCErr(resource, op, msg)
		}
	}

	// NewNotFoundSVCErrGen is a generator function for building NotFoundSVCErrs with the specified
	// resource supplied to all not found errs created.
	NewNotFoundSVCErrGen = func(resource string) NotFoundSVCErrGenFn {
		return func(op, msg string) *NotFoundSVCErr {
			return NewNotFoundSVCErr(resource, op, msg)
		}
	}

	// NewConflictSVCErrGen is a generator function for building ConflictSVCErrs with the specified
	// resource supplied to all conflict errs created.
	NewConflictSVCErrGen = func(resource string) ConflictSVCErrGenFn {
		return func(op, msg string) *ConflictSVCErr {
			return NewConflictSVCErr(resource, op, msg)
		}
	}

	// NewTemporarySVCErrGen is a generator function for building TemporarySVCErrs with the specified
	// resource supplied to all conflict errs created.
	NewTemporarySVCErrGen = func(resource string) TemporarySVCErrGenFn {
		return func(op, msg string) *TemporarySVCErr {
			return NewTemporarySVCErr(resource, op, msg)
		}
	}
)

Functions

func Append

func Append(old, new error) error

Append adds a new error to an existing (possibly nil) error.

func NewClientErr

func NewClientErr(op string, err error, resp *http.Response, opts ...ClientOptFn) error

NewClientErr is a constructor for a client error. The provided options allow the caller to set an optional retry.

Types

type ClientErr

type ClientErr struct {
	StatusCode int
	// contains filtered or unexported fields
}

ClientErr is an error type that provides useful error messages that include both request and response bodies, status code of response and valid request parameters.

func (*ClientErr) BackoffMessage

func (e *ClientErr) BackoffMessage() string

BackoffMessage provides a condensed error message that can be consumed during a backoff loop.

func (*ClientErr) Error

func (e *ClientErr) Error() string

Error returns the full client error message.

func (*ClientErr) Exists

func (e *ClientErr) Exists() bool

Exists provides the Exister behavior.

func (*ClientErr) NotFound

func (e *ClientErr) NotFound() bool

NotFound provides the NotFounder behavior.

func (*ClientErr) Retry

func (e *ClientErr) Retry() bool

Retry provides the retry behavior.

func (*ClientErr) Unwrap

func (e *ClientErr) Unwrap() error

Unwrap returns the wrapped error.

type ClientOptFn

type ClientOptFn func(o *ClientErr) *ClientErr

ClientOptFn is a optional parameter that allows one to extend a client error.

func Exists

func Exists() ClientOptFn

Exists sets the client error to Exists, exists=true.

func Meta

func Meta(key, value string, pairs ...string) ClientOptFn

Meta sets key value pairs to add context to the error output.

func NotFound

func NotFound() ClientOptFn

NotFound sets the client error to NotFound, notFound=true.

func Retry

func Retry() ClientOptFn

Retry sets the option and subsequent client error to retriable, retry=true.

type ConflictSVCErr

type ConflictSVCErr struct {
	*SVCErr
}

ConflictSVCErr is a service error for a conflict behavior.

func NewConflictSVCErr

func NewConflictSVCErr(resource, op, msg string) *ConflictSVCErr

NewConflictSVCErr is constructor for a ConflictSVC error.

func (*ConflictSVCErr) Conflict

func (*ConflictSVCErr) Conflict() bool

Conflict provides the conflict behavior.

type ConflictSVCErrGenFn

type ConflictSVCErrGenFn func(op, msg string) *ConflictSVCErr

ConflictSVCErrGenFn is a function for generating a conflict error from the supplied operation and errMsg parameters.

type Conflicter

type Conflicter interface {
	Conflict() bool
}

Conflicter determines if an error exhibits the behavior of a conflict err. This corresponds to times when you receive unexpected errors or an error of high severity.

type Exister

type Exister interface {
	Exists() bool
}

Exister determines if an error exhibits the behavior of a resource already exists err.

type ExistsErrGenFn

type ExistsErrGenFn func(op, msg string) *ExistsSVCErr

ExistsErrGenFn is a function for generating an exists error from the supplied operation and errMsg paramets.

type ExistsSVCErr

type ExistsSVCErr struct {
	*SVCErr
}

ExistsSVCErr is a service error for an exists behavior.

func NewExistsSVCErr

func NewExistsSVCErr(resource, op, msg string) *ExistsSVCErr

NewExistsSVCErr is a constructor for an ExistsSVCErr.

func (*ExistsSVCErr) Exists

func (*ExistsSVCErr) Exists() bool

Exists provides the exists behavior.

type HTTP

type HTTP interface {
	StatusCode() int
}

HTTP determines if an error exhibits the behavior of an error that provides an HTTP status code and the error message itself is safe for returning to a client.

type HTTPErr

type HTTPErr struct {
	Msg  string
	Code int
}

HTTPErr is a error that provides a status code and a message that is safe for clients to view.

func (*HTTPErr) Error

func (h *HTTPErr) Error() string

Error provides an error message.

func (*HTTPErr) StatusCode

func (h *HTTPErr) StatusCode() int

StatusCode provides the status code associated with the error message.

type HTTPInternalMessageError

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

HTTPInternalMessageError provides a status code, message safe for clients to view, and wraps an error for logging internally.

func NewHTTPInternalMessageError

func NewHTTPInternalMessageError(err error, msg string, code int) *HTTPInternalMessageError

NewHTTPInternalMessageError initializes an HTTPInternalMessageError.

func (*HTTPInternalMessageError) Error

func (e *HTTPInternalMessageError) Error() string

Error provides the client-safe error message

func (*HTTPInternalMessageError) InternalErrorMessage

func (e *HTTPInternalMessageError) InternalErrorMessage() string

InternalErrorMessage provides the internal-only wrapped error message.

func (*HTTPInternalMessageError) StatusCode

func (e *HTTPInternalMessageError) StatusCode() int

StatusCode provides the http status code associated with this message.

type InternalErrorMessage

type InternalErrorMessage interface {
	InternalErrorMessage() string
}

InternalErrorMessage provides a message separate from that returned by a call to Error() that is for internal (non-client) consumption.

type NotFoundSVCErr

type NotFoundSVCErr struct {
	*SVCErr
}

NotFoundSVCErr is a service error for a not found behavior.

func NewNotFoundSVCErr

func NewNotFoundSVCErr(resource, op, msg string) *NotFoundSVCErr

NewNotFoundSVCErr is a constructor for a NotFoundSVC error.

func (*NotFoundSVCErr) NotFound

func (*NotFoundSVCErr) NotFound() bool

NotFound provides the not found behavior.

type NotFoundSVCErrGenFn

type NotFoundSVCErrGenFn func(op, msg string) *NotFoundSVCErr

NotFoundSVCErrGenFn is a function for generating a not found error from the supplied operation and errMsg parameters.

type NotFounder

type NotFounder interface {
	NotFound() bool
}

NotFounder determines if an error exhibits the behavior of a resource not found err.

type Retrier

type Retrier interface {
	Retry() bool
}

Retrier determines if an error exhibits the behavior of an error that is safe to retry. TODO: a lot of times these types of errors may respond with a time/duration for when a retry is safe to commence. May be worth considering.

type SVCErr

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

SVCErr is a service error for that provides the basic data for all service errors.

func NewSVCErr

func NewSVCErr(resource, op, msg string) *SVCErr

NewSVCErr is a constructor for the SVCErr.

func (*SVCErr) Error

func (svcErr *SVCErr) Error() string

Error provides the error behavior.

type Temporarier

type Temporarier interface {
	Temporary() bool
}

Temporarier determines if an error exhibits the behavior of a system with services that are unreachable for whatever reason and are temporarily unavailable.

type TemporarySVCErr

type TemporarySVCErr struct {
	*SVCErr
}

TemporarySVCErr is a service error for a temporary behavior.

func NewTemporarySVCErr

func NewTemporarySVCErr(resource, op, msg string) *TemporarySVCErr

NewTemporarySVCErr is constructor for a TemporarySVC error.

func (*TemporarySVCErr) Temporary

func (*TemporarySVCErr) Temporary() bool

Temporary provides the conflict behavior.

type TemporarySVCErrGenFn

type TemporarySVCErrGenFn func(op, msg string) *TemporarySVCErr

TemporarySVCErrGenFn is a function for generating a temporary error from the supplied operation and errMsg parameters.

Jump to

Keyboard shortcuts

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