statuserr

package
v0.4.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusCode

func StatusCode(err error, fallback int) int

StatusCode returns the HTTP status carried by err, or fallback when none is available.

func Wrap

func Wrap(err error, fallback int) error

Wrap returns err unchanged if it already carries an HTTP status code. Otherwise it wraps err with fallback so callers can handle it uniformly.

Types

type HTTPStatusError

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

HTTPStatusError describes a failure with an HTTP status code.

func New

func New(status int, msg string) *HTTPStatusError

New constructs an error with the given HTTP status and message.

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

func (*HTTPStatusError) StatusCode

func (e *HTTPStatusError) StatusCode() int

type StatusCoder

type StatusCoder interface {
	StatusCode() int
}

StatusCoder is implemented by errors that carry an HTTP status code.

type StatusError

type StatusError interface {
	error
	StatusCoder
}

StatusError is implemented by errors that carry an HTTP status code.

Jump to

Keyboard shortcuts

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