httperror

package
v0.11.2 Latest Latest
Warning

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

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

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