Documentation
¶
Overview ¶
Package fabriqerr holds the canonical shared error values used across fabriq's core packages. The root fabriq package aliases everything here (fabriq.ErrNotFound, fabriq.VersionConflictError, ...) — application code should depend on those aliases; core and adapter packages depend on this leaf so the dependency direction stays root -> core.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound: aggregate or row absent within the tenant's scope. ErrNotFound = errors.New("fabriq: not found") // ErrVersionConflict: optimistic-concurrency mismatch. ErrVersionConflict = errors.New("fabriq: version conflict") // ErrProjectionLag: WaitForProjection deadline expired. ErrProjectionLag = errors.New("fabriq: projection lagging") // ErrStoreNotConfigured: capability port without a configured backend. ErrStoreNotConfigured = errors.New("fabriq: store not configured") // ErrQueryTimeout is returned when a query exceeds its time budget — the // statement_timeout fires (pg SQLSTATE 57014) or the context deadline is hit. ErrQueryTimeout = errors.New("fabriq: query exceeded the time limit") // ErrRawSQLUnsupported is returned by RelationalQuerier.Query on backends // that have no raw-SQL escape hatch (e.g. the in-memory test fake). // Callers may fall back to portable reads built from List/Get instead. ErrRawSQLUnsupported = errors.New("fabriq: relational backend does not execute raw SQL") )
Functions ¶
func SafeMessage ¶ added in v0.0.4
SafeMessage returns the default caller-facing message for a Code. Callers that have nothing more specific to say pass this to New/Wrap.
Types ¶
type Code ¶ added in v0.0.4
type Code string
Code is a stable, machine-readable error category. Every driver and layer maps its failures into one of these; HTTP and RPC boundaries switch on Code rather than matching on error-message substrings.
const ( CodeNotFound Code = "not_found" CodeAlreadyExists Code = "already_exists" CodeConstraintViolation Code = "constraint_violation" CodeSchemaMismatch Code = "schema_mismatch" CodeInvalidInput Code = "invalid_input" CodeVersionConflict Code = "version_conflict" CodePermissionDenied Code = "permission_denied" CodeTimeout Code = "timeout" CodeSerialization Code = "serialization" CodeNotConfigured Code = "not_configured" CodeInternal Code = "internal" )
type Error ¶ added in v0.0.4
type Error struct {
Code Code `json:"code"`
Message string `json:"message"`
Entity string `json:"entity,omitempty"`
ID string `json:"id,omitempty"`
Op string `json:"op,omitempty"`
Meta Meta `json:"meta,omitempty"`
Retryable bool `json:"retryable"`
// contains filtered or unexported fields
}
Error is fabriq's canonical structured error. Message is always safe to show a caller and never contains driver text; the underlying driver error is kept as cause (reachable via errors.As / Unwrap) but never serialized as-is.
type Meta ¶ added in v0.0.4
type Meta struct {
Driver string `json:"driver,omitempty"`
SQLState string `json:"sqlstate,omitempty"`
Constraint string `json:"constraint,omitempty"`
Table string `json:"table,omitempty"`
Column string `json:"column,omitempty"`
Detail map[string]string `json:"detail,omitempty"`
}
Meta carries structured, driver-native detail. Fields are decomposed (never a raw driver dump); Detail holds driver-specific extras with no typed slot.
type NotFoundError ¶
NotFoundError reports a missing aggregate within the tenant's scope.
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
func (*NotFoundError) Is ¶
func (e *NotFoundError) Is(target error) bool
Is makes errors.Is(err, ErrNotFound) match.
type Option ¶ added in v0.0.4
type Option func(*Error)
Option configures an Error at construction.
func WithEntity ¶ added in v0.0.4
func WithRetryable ¶ added in v0.0.4
type VersionConflictError ¶
VersionConflictError reports an optimistic-concurrency failure.
func (*VersionConflictError) Error ¶
func (e *VersionConflictError) Error() string
func (*VersionConflictError) Is ¶
func (e *VersionConflictError) Is(target error) bool
Is makes errors.Is(err, ErrVersionConflict) match.