fault

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package fault defines transport-neutral semantic error kinds.

Feature packages expose a Kind through Provider without importing the HTTP or future gRPC policy layers. Transports can then map the same semantic kind independently while domain code can override that default at its boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind string

Kind identifies the semantic category of an error independently of any transport status code.

const (
	KindUnknown       Kind = ""
	KindNotFound      Kind = "not_found"
	KindAlreadyExists Kind = "already_exists"
	KindConstraint    Kind = "constraint"
	KindSerialization Kind = "serialization"
	KindDeadlock      Kind = "deadlock"
	KindContention    Kind = "contention"
	KindConflict      Kind = "conflict"
	KindTimeout       Kind = "timeout"
	KindUnavailable   Kind = "unavailable"
	KindReadOnly      Kind = "read_only"
)

Semantic error kinds understood by Credo's default transport policies.

func KindOf

func KindOf(err error) (Kind, bool)

KindOf finds the first semantic Kind in err's unwrap/join tree.

type Provider

type Provider interface {
	error
	FaultKind() Kind
}

Provider is implemented by errors that expose a transport-neutral semantic kind. Implementations must keep sensitive driver metadata out of FaultKind.

func ProviderOf

func ProviderOf(err error) (Provider, bool)

ProviderOf finds the first non-nil Provider in err's unwrap/join tree. A provider returning KindUnknown is still returned so transport policy can fail closed instead of falling through to an unrelated legacy interface.

Jump to

Keyboard shortcuts

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