Documentation
¶
Overview ¶
Package errors defines flexitype's typed domain errors. Interface layers map Code onto their transport (HTTP status, gRPC code); usecases and domain code create errors through the constructors so every failure carries a stable machine-readable code.
Index ¶
- func DetailsOf(err error) map[string]any
- func IsArchived(err error) bool
- func IsConflict(err error) bool
- func IsDependencyViolation(err error) bool
- func IsNotFound(err error) bool
- func IsValidation(err error) bool
- type Code
- type Error
- func NewArchived(entity, id string) *Error
- func NewConflict(message string, kv ...any) *Error
- func NewDependencyViolation(message string, kv ...any) *Error
- func NewForbidden(message string, kv ...any) *Error
- func NewNotFound(entity, id string) *Error
- func NewValidation(message string, kv ...any) *Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsArchived ¶
IsArchived reports whether err carries CodeArchived.
func IsConflict ¶
IsConflict reports whether err carries CodeConflict.
func IsDependencyViolation ¶
IsDependencyViolation reports whether err carries CodeDependency.
func IsNotFound ¶
IsNotFound reports whether err carries CodeNotFound.
func IsValidation ¶
IsValidation reports whether err carries CodeValidation.
Types ¶
type Code ¶
type Code string
Code classifies a domain failure.
const ( // CodeValidation marks malformed or rule-violating input. CodeValidation Code = "VALIDATION" // CodeNotFound marks a missing aggregate. CodeNotFound Code = "NOT_FOUND" // CodeConflict marks uniqueness or concurrency conflicts. CodeConflict Code = "CONFLICT" // CodeArchived marks mutations against archived aggregates. CodeArchived Code = "ARCHIVED" // CodeDependency marks values rejected by an attribute dependency. CodeDependency Code = "DEPENDENCY_VIOLATION" // CodeForbidden marks an action the principal is not permitted to take // (e.g. writing a field their permission set denies). CodeForbidden Code = "FORBIDDEN" )
type Error ¶
Error is a typed domain error with structured details.
func NewArchived ¶
NewArchived builds a CodeArchived error for an entity/ID pair.
func NewConflict ¶
NewConflict builds a CodeConflict error.
func NewDependencyViolation ¶
NewDependencyViolation builds a CodeDependency error.
func NewForbidden ¶
NewForbidden builds a CodeForbidden error.
func NewNotFound ¶
NewNotFound builds a CodeNotFound error for an entity/ID pair.
func NewValidation ¶
NewValidation builds a CodeValidation error. Details are optional key/value pairs: NewValidation("bad name", "name", got).