richerror

package
v0.0.0-...-ecc908a Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int
const (
	KindUnknown Kind = iota
	KindStatusContinue
	KindStatusSwitchingProtocols
	KindStatusProcessing
	KindStatusEarlyHints

	KindStatusOK
	KindStatusCreated
	KindStatusAccepted
	KindStatusNonAuthoritativeInfo
	KindStatusNoContent
	KindStatusResetContent
	KindStatusPartialContent
	KindStatusMultiStatus
	KindStatusAlreadyReported
	KindStatusIMUsed

	KindStatusMultipleChoices
	KindStatusMovedPermanently
	KindStatusFound
	KindStatusSeeOther
	KindStatusNotModified
	KindStatusUseProxy
	KindUnderscore // Kind_
	KindStatusTemporaryRedirect
	KindStatusPermanentRedirect

	KindStatusBadRequest
	KindStatusUnauthorized
	KindStatusPaymentRequired
	KindStatusForbidden
	KindStatusNotFound
	KindStatusMethodNotAllowed
	KindStatusNotAcceptable
	KindStatusProxyAuthRequired
	KindStatusRequestTimeout
	KindStatusConflict
	KindStatusGone
	KindStatusRequestedRangeNotSatisfiable
	KindStatusExpectationFailed
	KindStatusTeapot
	KindStatusMisdirectedRequest
	KindStatusUnprocessableEntity
	KindStatusLocked
	KindStatusFailedDependency
	KindStatusTooEarly
	KindStatusUpgradeRequired
	KindStatusPreconditionRequired
	KindStatusTooManyRequests
	KindStatusRequestHeaderFieldsTooLarge
	KindStatusUnavailableForLegalReasons

	KindStatusInternalServerError
	KindStatusNotImplemented
	KindStatusBadGateway
	KindStatusServiceUnavailable
	KindStatusGatewayTimeout
	KindStatusHTTPVersionNotSupported
	KindStatusVariantAlsoNegotiates
	KindStatusInsufficientStorage
	KindStatusLoopDetected
	KindStatusNotExtended
	KindStatusNetworkAuthenticationRequired
)

type Op

type Op string

Op represents the operation where the error occurred.

type RichError

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

RichError is the main implementation of the RichErrorInterface.

func Analysis

func Analysis(err error) RichError

Analysis extracts RichError from a generic error.

func New

func New(op Op) *RichError

New creates a new RichError.

func (*RichError) Error

func (e *RichError) Error() string

Error implements the error interface.

func (*RichError) Kind

func (e *RichError) Kind() Kind

Kind returns the kind of the error. It checks wrapped errors recursively if the kind is not set.

func (*RichError) Message

func (e *RichError) Message() string

Message returns the error message. It falls back to wrapped errors recursively if no message is set.

func (*RichError) Meta

func (e *RichError) Meta() map[string]interface{}

Meta aggregates metadata from the current and wrapped errors.

func (*RichError) Op

func (e *RichError) Op() Op

Op returns the operation where the error occurred. It tries to fetch the operation from wrapped errors if not set.

func (*RichError) ToJSON

func (e *RichError) ToJSON() (string, error)

ToJSON serializes the error to JSON.

func (*RichError) WithErr

func (e *RichError) WithErr(err error) *RichError

WithErr wraps another error.

func (*RichError) WithKind

func (e *RichError) WithKind(kind Kind) *RichError

WithKind sets the error kind.

func (*RichError) WithMessage

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

WithMessage sets the error message.

func (*RichError) WithMeta

func (e *RichError) WithMeta(meta map[string]interface{}) *RichError

WithMeta adds metadata to the error. func (e *RichError) WithMeta(key string, value interface{}) *RichError {

func (*RichError) WrappedError

func (e *RichError) WrappedError() error

WrappedError returns the wrapped error.

Jump to

Keyboard shortcuts

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