status

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 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.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. If an error consists of more wrapped HTTP errors, only one is returned but not deterministically.

Types

This section is empty.

Jump to

Keyboard shortcuts

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