errors

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 License: Apache-2.0 Imports: 5 Imported by: 5

Documentation

Overview

Package errors provides convenience functions for Kivik drivers to report meaningful errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause is a wrapper around pkg/errors.Cause()

func Errorf

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

Errorf is a wrapper around pkg/errors.Errorf()

func New

func New(msg string) error

New is a wrapper around the standard errors.New, to avoid the need for multiple imports.

func Reason

func Reason(err error) string

Reason returns the error's reason if there is one.

func Status

func Status(status int, msg string) error

Status returns a new error with the designated HTTP status.

func StatusCode

func StatusCode(err error) int

StatusCode extracts an embedded HTTP status code from an error.

func Statusf

func Statusf(status int, format string, args ...interface{}) error

Statusf returns a new error with the designated HTTP status.

func Wrap

func Wrap(err error, msg string) error

Wrap is a wrapper around pkg/errors.Wrap()

func WrapStatus

func WrapStatus(status int, err error) error

WrapStatus bundles an existing error with a status code.

func Wrapf

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

Wrapf is a wrapper around pkg/errors.Wrapf()

Types

type Reasoner

type Reasoner interface {
	Reason() string
}

Reasoner is an interface for an error that contains a reason.

type StatusCoder

type StatusCoder interface {
	StatusCode() int
}

StatusCoder is an optional error interface, which returns the error's embedded HTTP status code.

type StatusError

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

StatusError is an error message bundled with an HTTP status code.

func (*StatusError) Error

func (se *StatusError) Error() string

func (*StatusError) MarshalJSON added in v1.0.5

func (se *StatusError) MarshalJSON() ([]byte, error)

MarshalJSON satisifies the json.Marshaler interface for the StatusError type.

func (*StatusError) Reason

func (se *StatusError) Reason() string

Reason returns the error's underlying reason.

func (*StatusError) StatusCode

func (se *StatusError) StatusCode() int

StatusCode returns the StatusError's embedded HTTP status code.

Jump to

Keyboard shortcuts

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