httperror

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 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(code int, msg string) error

New constructs a new E with code and error message.

func Newf

func Newf(code int, format string, args ...any) error

Newf constructs a new E with code and error message formatted with fmt.Sprintf.

func Wrap

func Wrap(code int, err error) error

Wrap wraps an error with in an E instance.

Types

type E

type E struct {
	// StatusCode is the HTTP status code this error is best represented by.
	StatusCode int
	E          error
}

E is the error struct that can be used with errors.As and errors.Is. Consumers of E are typically aware they're serving HTTP and consequently have sufficient context to set a StatusCode.

func (*E) Error

func (e *E) Error() string

Error satisfies the error interface.

Jump to

Keyboard shortcuts

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