apierror

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthenticated = &Error{
		Errors:     []string{http.StatusText(http.StatusUnauthorized)},
		StatusCode: http.StatusUnauthorized,
	}
	ErrISE = &Error{
		Errors:     []string{http.StatusText(http.StatusInternalServerError)},
		StatusCode: http.StatusInternalServerError,
	}
	ErrNotFound = &Error{
		Errors:     []string{http.StatusText(http.StatusNotFound)},
		StatusCode: http.StatusNotFound,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	ErrMethodNotAllowed = &Error{
		Errors:     []string{http.StatusText(http.StatusMethodNotAllowed)},
		StatusCode: http.StatusMethodNotAllowed,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	ErrForbidden = &Error{
		Errors:     []string{http.StatusText(http.StatusForbidden)},
		StatusCode: http.StatusForbidden,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	ErrUnimplemented = &Error{
		Errors:     []string{"unimplemented"},
		StatusCode: http.StatusNotImplemented,
	}
)

Functions

func ErrorHandler

func ErrorHandler(w http.ResponseWriter, _ *http.Request, err error)

func RequestErrorHandler

func RequestErrorHandler(w http.ResponseWriter, r *http.Request, err error)

func ResponseErrorHandler

func ResponseErrorHandler(w http.ResponseWriter, r *http.Request, err error)

Types

type Error

type Error struct {
	StatusCode int      `json:"-"`
	Errors     []string `json:"errors"`
}

func New

func New(statusCode int, message string) *Error

func (*Error) AsJSON

func (ae *Error) AsJSON() []byte

func (*Error) Error

func (ae *Error) Error() string

Jump to

Keyboard shortcuts

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