example

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTemporary

func IsTemporary(err error) bool

IsTemporary returns true if any error in the chain is a TemporaryError. This is just a shortcut to using the more verbose xerrors.Is call.

func NewMyError

func NewMyError(err error) error

NewMyError wraps an existing error, giving it type MyError

func NewTemporary

func NewTemporary(err error) error

NewTemporary wraps an existing error, giving it type TemporaryError.

func WithStatusCode

func WithStatusCode(err error, code int) error

WithStatusCode wraps an existing error, giving it a status code.

Types

type ErrStatusCode

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

ErrStatusCode is an error that holds some kind of status code.

func (*ErrStatusCode) Is

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

Is is true if err is of type ErrStatysCode.

func (*ErrStatusCode) StatusCode

func (e *ErrStatusCode) StatusCode() int

StatusCode returns the status code associated with this error. If .As returns true that an error is an ErrStatusCode, then this method may be used on the result.

func (*ErrStatusCode) Unwrap

func (e *ErrStatusCode) Unwrap() error

Unwrap returns the underlying error.

type MyError

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

MyError is an example of a custom error type that can be tested with .Is.

func (*MyError) Is

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

Is returns true if err is of type MyError.

func (*MyError) Unwrap

func (e *MyError) Unwrap() error

Unwrap returns the underlying error.

type TemporaryError

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

A TemporaryError is an example of a custom error that can be tested with .Is.

func (*TemporaryError) Is

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

Is returns true if err is of type NewTemporary.

func (*TemporaryError) Unwrap

func (e *TemporaryError) Unwrap() error

Unwrap returns the underlying error.

Jump to

Keyboard shortcuts

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