errors

package
v3.35.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package errors wraps pkg/errors and includes some custom features such as error codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

func Cause

func Cause(err error) error

func Errorf

func Errorf(format string, args ...interface{}) error

func Is

func Is(err error, target Code) bool

Is is a fork of the Is() method from `pkg/errors` which takes as its target an error Code instead of an error.

func MarshalJSON added in v3.33.0

func MarshalJSON(err error) string

MarshalJSON returns the provided error as a json object (as a string) representing a codedError. If err is not already a codedError, the json object will still represent a codedError but its `code` value will be empty. Note: an empty code here is intentional and is different from code `errors.Uncoded` which is a valid code; it just means the developer returned a codedError but didn't bother to choose (or create) a useful error code.

func New

func New(code Code, message string) error

func UnmarshalJSON added in v3.33.0

func UnmarshalJSON(r io.Reader) error

UnmarshalJSON converts the byte slice into a codedError. If the bytes can't unmarshal to a codedError, a normal error will be returned containing the string value of the byte slice.

func Unwrap

func Unwrap(err error) error

func WithMessage

func WithMessage(err error, message string) error

func WithMessagef

func WithMessagef(err error, format string, args ...interface{}) error

func WithStack

func WithStack(err error) error

func Wrap

func Wrap(err error, message string) error

func Wrapf

func Wrapf(err error, fmt string, args ...interface{}) error

Types

type Code

type Code string

Code is an error code which can be used to check against a given error. For example, see the Is() method.

const (
	ErrUncoded Code = "Uncoded"
)

Jump to

Keyboard shortcuts

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