errors

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errors defines all typed errors returned by chiauth services. Handlers translate these into appropriate HTTP status codes.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound          = errors.New("user not found")
	ErrEmailAlreadyExists    = errors.New("email already in use")
	ErrUsernameAlreadyExists = errors.New("username already in use")
	ErrInvalidCredentials    = errors.New("invalid email or password")
	ErrAccountNotActive      = errors.New("account not yet activated — check your email")
	ErrAccountLocked         = errors.New("account locked due to too many failed attempts")
	ErrAccountDeleted        = errors.New("account has been deleted")

	ErrTokenInvalid  = errors.New("token is invalid")
	ErrTokenExpired  = errors.New("token has expired")
	ErrTokenUsed     = errors.New("token has already been used")
	ErrTokenRevoked  = errors.New("token has been revoked")
	ErrTokenNotFound = errors.New("token not found")

	ErrRoleNotFound        = errors.New("role not found")
	ErrRoleAlreadyExists   = errors.New("role with this slug already exists")
	ErrRoleIsSystem        = errors.New("system roles cannot be deleted")
	ErrRoleAlreadyAssigned = errors.New("user already has this role")

	ErrPermissionNotFound       = errors.New("permission not found")
	ErrPermissionAlreadyExists  = errors.New("permission already exists")
	ErrPermissionAlreadyGranted = errors.New("user already has this permission")

	ErrUnauthorized = errors.New("unauthorized")
	ErrForbidden    = errors.New("forbidden — insufficient permissions")

	ErrWeakPassword  = errors.New("password does not meet minimum requirements")
	ErrSamePassword  = errors.New("new password must be different from current password")
	ErrWrongPassword = errors.New("current password is incorrect")

	ErrEmailSendFailed = errors.New("failed to send email")
)

Sentinel errors — compare with errors.Is()

Functions

This section is empty.

Types

type ValidationError

type ValidationError struct {
	Fields map[string]string
}

ValidationError holds field-level validation failures.

func NewValidationError

func NewValidationError(fields map[string]string) *ValidationError

NewValidationError constructs a ValidationError from a map of field→message.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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