httperror

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

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

Creates a new error with a format string

func Unwrap added in v0.3.0

func Unwrap(err error) (int, error)

Unwraps an http error to get the internal error and http status code. If the error is not an http error returns InternalServerError and a nil wrapped error

func Wrap

func Wrap(status int, wrapped error) error

Wraps an existing error with an http status code

Types

type HttpError

type HttpError struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	// contains filtered or unexported fields
}

Error containing an internal error and corresponding http response data

func Convert

func Convert(err error) *HttpError

Checks if the error is an http error. If it is, returns it cast as an HttpError If not, provides a new wrapped http error

func (HttpError) Error

func (err HttpError) Error() string

Jump to

Keyboard shortcuts

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