status

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package status is used to allow sorting of errors to http status codes.

Index

Constants

This section is empty.

Variables

View Source
var HTTP = map[int]error{
	http.StatusBadRequest:            errors.New("'bad request'"),
	http.StatusUnauthorized:          errors.New("'unauthorized'"),
	http.StatusForbidden:             errors.New("'forbidden'"),
	http.StatusNotFound:              errors.New("'not found'"),
	http.StatusConflict:              errors.New("'conflict'"),
	http.StatusGone:                  errors.New("'gone'"),
	http.StatusRequestEntityTooLarge: errors.New("'payload too large'"),
	http.StatusTooManyRequests:       errors.New("'too many requests'"),

	http.StatusInternalServerError: errors.New("'internal server error'"),
	http.StatusServiceUnavailable:  errors.New("'service unavailable'"),
}

Functions

func Add

func Add(err error, code int) error

Add adds http error at the beginning of the error.

func ErrToCode

func ErrToCode(err error) int

ErrToCode returns a http code for an error.

Works only if err is wrapped HTTP Error. Otherwise -1 is returned. By convention, each error must wrap at most one HTTP error from this package. Wrapping multiple ones is a bug — the returned code is then not deterministic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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