errors

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 6 Imported by: 38

Documentation

Overview

Package errors provides a way to return detailed information for a request error. The error is normally JSON encoded.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Stack adds stack trace to error, with message
	Stack = errors.New
	// Stackf adds stack trace to error, with format specifier
	Stackf = errors.Errorf
	// Wrap returns an error annotating err with a stack trace
	Wrap = errors.WithMessage
	// Wrapf returns an error annotating err with a stack trace
	Wrapf = errors.WithMessagef
	// NewHTTP creates a new error with the given id and code and detail
	NewHTTP = http.New
	// CodeHTTP gets the code of the given error
	CodeHTTP = http.Code
	// RegisterCode register a new error code with the given http.StatusCode,or overwriting any existing one
	RegisterCode = http.RegisterCode
)

Define alias from pkg/errors

View Source
var (
	// Errorf formats according to a format specifier and returns the string as a value that satisfies error
	Errorf = fmt.Errorf
	// Is reports whether any error in errs chain matches target
	Is = stderr.Is
	// As finds the first error in errs that matches target, and if one is found, sets target to that error value and returns true. Otherwise, it returns false.
	As = stderr.As
	// Unwrap unwraps the error, and if it is a wrapper, returns the next error in the chain.
	Unwrap = stderr.Unwrap
	// New creates a new error with the given string
	New = stderr.New
	// Join joins any number of errors into a single error.
	Join = stderr.Join
)

Define alias from stderr

View Source
var (
	// Append is a helper function that will append more merr
	Append = merr.Append
	// ListFormatFunc is a helper function that will format the merr
	ListFormatFunc = merr.ListFormatFunc
)

Functions

This section is empty.

Types

type ErrorFormatFunc

type ErrorFormatFunc = merr.ErrorFormatFunc

ErrorFormatFunc is a helper function that will format the merr

type MultiError

type MultiError = merr.Error

MultiError is an alias of `github.com/hashicorp/go-multierror`.Error

type StdError

type StdError string

func (StdError) Error

func (obj StdError) Error() string

HTTP returns the JSON representation of the error

func (StdError) Is

func (obj StdError) Is(err error) bool

func (StdError) String

func (obj StdError) String() string

type ThreadSafeMultiError

type ThreadSafeMultiError struct {
	ErrorFormat ErrorFormatFunc
	// contains filtered or unexported fields
}

ThreadSafeMultiError represents a collection of merr

func ThreadSafe

func ThreadSafe(err error, fns ...ErrorFormatFunc) *ThreadSafeMultiError

ThreadSafe creates a new ThreadSafeMultiError collection

func (*ThreadSafeMultiError) Append

func (e *ThreadSafeMultiError) Append(err error)

Append adds an error to the MultiError collection

func (*ThreadSafeMultiError) Error

func (e *ThreadSafeMultiError) Error() string

Error returns the JSON representation of the MultiError collection

func (*ThreadSafeMultiError) Errors

func (e *ThreadSafeMultiError) Errors() []error

Errors returns the merr collection

func (*ThreadSafeMultiError) Has

func (e *ThreadSafeMultiError) Has(err error) error

func (*ThreadSafeMultiError) HasErrors

func (e *ThreadSafeMultiError) HasErrors() bool

HasErrors checks if the MultiError collection has any merr

func (*ThreadSafeMultiError) Unsafe

func (e *ThreadSafeMultiError) Unsafe() *MultiError

Unsafe returns the MultiError collection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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