httperr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidID = &HTTPError{
		Err:        errors.New("invalid ID"),
		StatusCode: http.StatusBadRequest,
		Code:       "INVALID_ID",
	}
	ErrNotAuthenticated = &HTTPError{
		Err:        errors.New("not authenticated"),
		StatusCode: http.StatusUnauthorized,
		Code:       "NOT_AUTHENTICATED",
	}
)

Functions

This section is empty.

Types

type HTTPError

type HTTPError struct {
	Err        error
	StatusCode int
	Code       string
}

HTTPError represents an error with HTTP status and application code.

func New

func New(err error, status int, code string) *HTTPError

New returns an HTTPError with the given error, status code, and code.

func NewValidationErrorf

func NewValidationErrorf(format string, args ...any) *HTTPError

NewValidationErrorf creates an HTTPError with code VALIDATION_ERROR for dynamic validation messages.

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) HTTPStatus

func (e *HTTPError) HTTPStatus() int

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