errors

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 3 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 finds the first error in error's chain that matches target, and if so, sets target to that error value and returns true. Otherwise, it returns false.

func Is

func Is(err, target error) bool

Is used to check if the errors match or not

func New

func New(message string) error

New is used to create a new error

func Unwrap

func Unwrap(err error) error

Unwrap is used to unwrap the error to the details

func Wrap

func Wrap(parent, err error) error

Wrap is used to wrap the error into another

Types

type Error

type Error struct {
	StatusCode int         `json:"-"`
	Code       string      `json:"code"`
	Message    string      `json:"message"`
	Details    interface{} `json:"details,omitempty"`
	// contains filtered or unexported fields
}

Error is the type which can be used as an implementation of error

func (*Error) As

func (e *Error) As(target interface{}) bool

As is used to case the error type to the target

func (*Error) Error

func (e *Error) Error() string

Error is used to get the detail from the error

func (*Error) GetTrace

func (e *Error) GetTrace() string

GetTrace is used to get the current trace

func (*Error) Is

func (e *Error) Is(err error) bool

Is used to check if it matches the error provided

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap is used to unwrap the error to the details

func (*Error) Value

func (e *Error) Value() *Error

Value is used to get the reference to the value

func (*Error) WithDetails

func (e *Error) WithDetails(details interface{}) *Error

WithDetails is used to attach the details to the error response

func (*Error) WithMessage

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

WithMessage is used to create a new error with the message changed

func (*Error) WithStatusCode

func (e *Error) WithStatusCode(statusCode int) *Error

WithStatusCode is used to create a new error with the status code changed

func (*Error) Wrap

func (e *Error) Wrap(err error) error

Wrap is used to wrap the error

Jump to

Keyboard shortcuts

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