errors

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errors provides database error mapping to domain errors. Each mapper translates driver-specific errors (constraint violations, not-found, schema errors) into core/errors.AppError with appropriate codes.

Only the generic, dependency-light mappers live here (Postgres via pgx/pgconn). The Ent-ORM mapper is product-side (contracts/ent/errmap.MapEntError) because it imports the schema-generated ent error predicates; a product Ent store injects it as a DBMapperFunc — the seam type below — at its composition point.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBMapperFunc

type DBMapperFunc func(error) error

DBMapperFunc maps a database error to an *AppError. Implementations must return nil when the input error is nil. A concrete ORM mapper (e.g. the product's Ent mapper) is a DBMapperFunc value injected by the store that owns that ORM.

func NewDBMapper

func NewDBMapper(kind Kind) (DBMapperFunc, error)

NewDBMapper creates a DBMapperFunc for the specified kind. Returns an error if the kind is unknown.

type Kind

type Kind int

Kind specifies which built-in DB error mapper to use.

const (
	// KindPostgres maps PostgreSQL-specific errors (pgx, pgconn) to domain errors.
	KindPostgres Kind = iota
)

func (Kind) String

func (k Kind) String() string

String returns the string representation of Kind.

Directories

Path Synopsis
Package postgres provides PostgreSQL-specific DB error mapping.
Package postgres provides PostgreSQL-specific DB error mapping.

Jump to

Keyboard shortcuts

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