feat(ports): define consumer-side interfaces, sentinel errors, IsUniqueViolation

This commit is contained in:
2026-09-14 19:47:27 +08:00
parent f99f5a7878
commit 0c3b34c184
3 changed files with 126 additions and 0 deletions
+3
View File
@@ -13,6 +13,9 @@ import (
// ErrLastAdmin is returned by DeleteUser when attempting to delete the last admin.
var ErrLastAdmin = errors.New("cannot delete the last admin")
// ErrUniqueViolation is a sentinel for PostgreSQL unique constraint violations.
var ErrUniqueViolation = errors.New("unique violation")
// IsUniqueViolation reports whether err is a PostgreSQL unique constraint violation (23505).
func IsUniqueViolation(err error) bool {
var pgErr *pgconn.PgError