httperror

package
v0.16.7 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package httperror provides a shared error type that carries HTTP status codes for gateway responses. The gateway uses StatusCodeFrom(err) only.

Domain-specific mappers (wrap errors before returning to gateway):

  • gateway/rest.writeClusterError (calls clusterErrorToHTTP)
  • manifest.ManifestSubmitErrorToHTTP
  • gateway/utils.jwtErrorToHTTP (JWT parse errors)

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJWTMissing        = NewHttpError(http.StatusBadRequest, errors.New("JWT is missing"))
	ErrInvalidAuthHeader = NewHttpError(http.StatusBadRequest, errors.New("invalid authorization header"))
	ErrInvalidRequest    = NewHttpError(http.StatusBadRequest, errors.New("invalid request"))
	ErrJWTInvalidClaims  = NewHttpError(http.StatusBadRequest, errors.New("JWT has invalid claims"))
	ErrAuthAmbiguous     = NewHttpError(http.StatusBadRequest, errors.New("auth: ambiguous authentication. may not use mTLS and JWT at the same time"))

	ErrUnauthorized = NewHttpError(http.StatusUnauthorized, errors.New("unauthorized access"))
	ErrJWTInvalid   = NewHttpError(http.StatusUnauthorized, errors.New("JWT is invalid"))
	ErrJWTExpired   = NewHttpError(http.StatusUnauthorized, errors.New("JWT is expired"))
)

Functions

func StatusCodeFrom

func StatusCodeFrom(err error) int

Types

type HttpError

type HttpError struct {
	Err        error
	StatusCode int
}

HttpError wraps an error with the appropriate HTTP status code.

func NewHttpError

func NewHttpError(statusCode int, err error) *HttpError

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Unwrap

func (e *HttpError) Unwrap() error

Jump to

Keyboard shortcuts

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