apierror

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPermission = errors.New("you do not have permission to do that")
	ErrNoSession    = errors.New("no session found")
	ErrInternal     = errors.New("internal error")
	ErrConflict     = errors.New("conflict")
	ErrNotFound     = errors.New("not found")
	ErrMethod       = errors.New("method not allowed")

	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	APIErrNoPermission = &Error{
		Errors:     []string{ErrNoPermission.Error()},
		StatusCode: http.StatusUnauthorized,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	APIErrNoSession = &Error{
		Errors:     []string{ErrNoSession.Error()},
		StatusCode: http.StatusUnauthorized,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	APIErrInternal = &Error{
		Errors:     []string{ErrInternal.Error()},
		StatusCode: http.StatusInternalServerError,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	APIErrNotFound = &Error{
		Errors:     []string{ErrNotFound.Error()},
		StatusCode: http.StatusNotFound,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	APIErrMethodNotAllowed = &Error{
		Errors:     []string{ErrMethod.Error()},
		StatusCode: http.StatusMethodNotAllowed,
	}
	//nolint:errname // This is intentional to separate pure error types from wrapper API Errors.
	APIErrForbidden = &Error{
		Errors:     []string{ErrNoPermission.Error()},
		StatusCode: http.StatusForbidden,
	}
)

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:"statusCode"`
	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