errors

package
v0.0.0-...-6343e97 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrUnknown is returned when an unexpected error occurs.
	ErrUnknown = Error("err_unknown: unknown error occurred")
	// ErrInvalidRequest is returned when either the parameters or the request body is invalid.
	ErrInvalidRequest = Error("err_invalid_request: invalid request received")
	// ErrValidation is returned when the parameters don't pass validation.
	ErrValidation = Error("err_validation: failed validation")
	// ErrNotFound is returned when the requested resource is not found.
	ErrNotFound = Error("err_not_found: not found")
)
View Source
const ErrSeperator = " -- "

ErrSeperator is used to determine the boundaries of the errors in the hierarchy.

Variables

This section is empty.

Functions

func As

func As(err error, target any) bool

As just wraps errors.As as we don't want to alias the errors package everywhere to use it.

func Is

func Is(err error, target error) bool

Is just wraps errors.Is as we don't want to alias the errors package everywhere to use it.

func New

func New(message string) error

New just wraps errors.New as we don't want to alias the errors package everywhere to use it.

Types

type Error

type Error string

Error allows errors to be defined as const errors preventing modification and allowing them to be evaluated against wrapped errors.

func (Error) As

func (s Error) As(target interface{}) bool

As implements As(interface{}) bool which is used by errors.As (https://golang.org/pkg/errors/#As) allowing a Error to be set as the target if it matches the specified target type. This implementation only checks the top most wrapped error.

func (Error) Error

func (s Error) Error() string

func (Error) Is

func (s Error) Is(target error) bool

Is implements https://golang.org/pkg/errors/#Is allowing a Error to check it is the same even when wrapped. This implementation only checks the top most wrapped error.

func (Error) Wrap

func (s Error) Wrap(err error) error

Wrap allows errors to wrap an error returned from a 3rd party in a const service error preserving the original cause.

Jump to

Keyboard shortcuts

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