httperr

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package httperr provides HTTP-centric extensions to standard errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bury

func Bury(status int, err error, msg string) error

Bury buries err, exposing only msg to the end user. err is still accessible through Cause()

func Buryf

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

Buryf works like Bury.

func Errorf

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

Errorf wraps pkg/errors.Errorf()

func HTTPStatus added in v0.14.0

func HTTPStatus(err error) int

HTTPStatus attempts to extract the HTTP status code from err, falling back to http.StatusInternalServerError if none is found.

func New

func New(status int, msg string) error

New wraps pkg/errors.New()

func StatusCode deprecated

func StatusCode(err error) int

StatusCode is an alias for HTTPStatus.

Deprecated: Use HTTPStatus.

func WithStack

func WithStack(status int, err error) error

WithStack wraps pkg/errors.WithStack()

func WithStatus

func WithStatus(status int, err error) error

WithStatus attaches a status code to an existing error.

func Wrap

func Wrap(status int, err error, msg string) error

Wrap wraps pkg/errors.Wrap()

func Wrapf

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

Wrapf wraps pkg/errors.Wrapf()

Types

type Standard

type Standard int

Standard converts a standard HTTP status code into a useable error

func (Standard) Error

func (e Standard) Error() string

func (Standard) HTTPStatus added in v0.14.0

func (e Standard) HTTPStatus() int

HTTPStatus returns e.

func (Standard) StatusCode

func (e Standard) StatusCode() int

StatusCode returns e.

Jump to

Keyboard shortcuts

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