apperr

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppError

type AppError struct {
	Code    string // machine-readable: "LICENSE_NOT_FOUND", "ACTIVATION_LIMIT"
	Message string // human-readable
	Status  int    // HTTP status code
	Details any    // optional structured details
	Cause   error  // underlying error (not exposed to clients)
}

AppError is the standard application error type. Handlers translate these into the appropriate HTTP status + response envelope.

func BadRequest

func BadRequest(message string) *AppError

func Conflict

func Conflict(code, message string) *AppError

func Forbidden

func Forbidden(message string) *AppError

func Internal

func Internal(cause error) *AppError

func New

func New(status int, code, message string) *AppError

func NotFound

func NotFound(entity, id string) *AppError

func Unauthorized

func Unauthorized(message string) *AppError

func ValidateEmail

func ValidateEmail(email string) *AppError

func ValidateName

func ValidateName(field, value string) *AppError

func ValidateSemver added in v0.1.1

func ValidateSemver(value string) *AppError

ValidateSemver returns nil iff value is a strict SemVer 2.0 version string. Leading zeros (e.g. `01.0.0`), empty pre-release identifiers, and other 2.0 violations are rejected. Empty input is rejected — call sites that allow "no version" must short-circuit before calling.

func ValidateSlug

func ValidateSlug(value string) *AppError

func ValidateURL

func ValidateURL(value string) *AppError

func WithDetails

func WithDetails(err *AppError, details any) *AppError

func Wrap

func Wrap(status int, code, message string, cause error) *AppError

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) Unwrap

func (e *AppError) Unwrap() error

Jump to

Keyboard shortcuts

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