Documentation
¶
Overview ¶
Package errors centralizes public error codes and classification helpers.
Keeping protocol-facing error strings in one package gives NornicDB a single place to manage retryability, wire-code mapping, and future localization.
Author: Codex, NOR-180 terminal diagnostic ownership, 2026-11-01.
Author: Codex, NOR-180 status-diagnostic propagation, 2026-10-27.
Author: Codex, NOR-180 one carrier discovery across projection and cause, 2026-11-01. Author: Claude, NOR-180 single render pass, 2026-10-30.
Author: Codex, NOR-180 immutable outcome/read ownership, 2026-11-01. Author: Codex,NOR-180 immutable terminal outcomes,29October2026; discovery and composition through the one error walk (statusScan) by Claude, 30 October 2026; the committed-outcome retry rule (committedStatus), the one committed representation, the invocation's committed work, and committed truth by construction (one view and carrier constructor) by Claude, 30 October 2026.
Author: Codex, NOR-180 immutable outcome composition, 29 October 2026; the invocation's committed work by Claude, 30 October 2026.
Index ¶
- Constants
- Variables
- func AppendStatusDiagnostics(err error, message string, render func(localization.Message) string) string
- func CombineTerminalOutcomes(primary error, required ...error) error
- func HasNeo4jStatus(err error) bool
- func HasStatusDiagnostic(err error) bool
- func HasTerminalOutcome(err error) bool
- func IsCommitRolledBack(err error) bool
- func IsCompileTimeError(err error) bool
- func IsCompileTimeStatus(code string) bool
- func IsMergeCommitTimeUniqueConflict(err error) bool
- func IsRetriableStatus(code string) bool
- func IsTransientTransactionError(err error) bool
- func MarkCommitRolledBack(err error) error
- func MarkCompileTime(err error) error
- func MarkMergeCommitTimeUniqueConflict(err error) error
- func MarkStatementTimeout(err, cause error) error
- func Neo4jStatus(err error) (code, message string)
- func NormalizeTerminalOutcome(err error) error
- func ProjectTerminalOutcomeMessages(err error, project func(error) error) error
- func RecordCommittedWork(ctx context.Context)
- func RecordTerminalOutcome(ctx context.Context, outcome error)
- func RenderStatus(err error, render func(localization.Message) string) (code, message string)
- func RenderStatusWithFallback(err error, render func(localization.Message) string, ...) (code, message string)
- func TransactionControlFailure(op TerminalOperation, err error) error
- func WithStatus(cause error, code string, message localization.Message) error
- type Localized
- type TerminalFailure
- type TerminalOperation
- type TerminalOutcomeScope
- type TerminalOutcomes
Constants ¶
const ( // TransientDeadlockDetected is the retryable wire error code for lock deadlocks. TransientDeadlockDetected = "Neo.TransientError.Transaction.DeadlockDetected" // TransientOutdated is the retryable wire error code for stale MVCC snapshots. TransientOutdated = "Neo.TransientError.Transaction.Outdated" // is briefly unavailable, such as while a restore replaces its store. TransientDatabaseUnavailable = "Neo.TransientError.General.DatabaseUnavailable" // ClientTransactionOutOfMemory is Neo4j's code for a transaction that used // more memory than one transaction may. NornicDB reports Badger's "Txn is // too big" with it (#703). It is a ClientError, not transient: retrying // the same transaction fails the same way, so drivers must not retry it. ClientTransactionOutOfMemory = "Neo.ClientError.General.TransactionOutOfMemoryError" )
const ( // StatementSyntaxError is the status of a statement error with no more // specific classification. StatementSyntaxError = "Neo.ClientError.Statement.SyntaxError" // ConstraintValidationFailed is the status of a write that violates a // schema constraint (uniqueness, existence, key, type), as in Neo4j. ConstraintValidationFailed = "Neo.ClientError.Schema.ConstraintValidationFailed" // DatabaseTransactionCommitFailed is the status of a COMMIT that failed for a // reason with no more specific classification, including an infrastructure // failure while reading or decoding the committed state needed by a commit. DatabaseTransactionCommitFailed = "Neo.DatabaseError.Transaction.TransactionCommitFailed" // TransactionRollbackFailed is the status of a ROLLBACK that failed for a // reason with no more specific classification. TransactionRollbackFailed = "Neo.DatabaseError.Transaction.TransactionRollbackFailed" // TransactionStartFailed is the status of a BEGIN that failed for a reason // with no more specific classification. TransactionStartFailed = "Neo.DatabaseError.Transaction.TransactionStartFailed" // TransactionTimedOut is the status of a statement stopped by a timeout // the server configures (Neo4j's db.transaction.timeout; NornicDB's query // time limit and Bolt statement timeout). TransactionTimedOut = "Neo.ClientError.Transaction.TransactionTimedOut" // TransactionTimedOutClientConfiguration is the status of a statement or // transaction stopped by the timeout its client set when it started. TransactionTimedOutClientConfiguration = "Neo.ClientError.Transaction.TransactionTimedOutClientConfiguration" // TransactionTimedOutMessage and TransactionTimedOutClientConfigurationMessage // are Neo4j 5.26's messages for those statuses, trailing space included. TransactionTimedOutMessage = "" /* 254-byte string literal not displayed */ TransactionTimedOutClientConfigurationMessage = "" /* 256-byte string literal not displayed */ )
Variables ¶
var ( // ErrTransactionConflict aliases the storage conflict sentinel used when an // optimistic transaction observes data changed after its snapshot. ErrTransactionConflict = storage.ErrConflict // ErrMVCCResourcePressure aliases the storage admission sentinel used when a // snapshot cannot be kept alive under current MVCC pressure. ErrMVCCResourcePressure = storage.ErrMVCCResourcePressure // ErrMVCCSnapshotGracefulCancel aliases the storage sentinel for snapshots // cancelled during high MVCC pressure. ErrMVCCSnapshotGracefulCancel = storage.ErrMVCCSnapshotGracefulCancel // ErrMVCCSnapshotHardExpired aliases the storage sentinel for snapshots // forcibly expired during critical MVCC pressure. ErrMVCCSnapshotHardExpired = storage.ErrMVCCSnapshotHardExpired // ErrTransactionDeadlock aliases the storage deadlock sentinel: lock waits that drivers should // retry as Neo4j-compatible transient transaction failures. ErrTransactionDeadlock = storage.ErrDeadlock // ErrMergeCommitTimeUniqueConflict marks a commit-time UNIQUE violation from // a concurrent MERGE race. Retry-aware clients can safely replay because the // winner's committed node will be observed on the next attempt. ErrMergeCommitTimeUniqueConflict = stderrors.New("merge commit-time unique conflict") // Procedure catalog lifecycle errors. ErrProcedureCatalogReadFailed = stderrors.New("cypher: procedure catalog read failed") ErrProcedureCatalogRecordDecodeFailed = stderrors.New("cypher: procedure catalog record decode failed") ErrProcedureCatalogRecordInvalid = stderrors.New("cypher: procedure catalog record invalid") ErrProcedureRegistryReloadFailed = stderrors.New("cypher: procedure registry reload failed") // DDL parse/validation errors. ErrInvalidFulltextRelationshipTypes = stderrors.New("cypher: invalid fulltext relationship types") ErrInvalidMergeChainQuery = stderrors.New("cypher: invalid merge chain query") // ErrExpressionEvaluationFailed marks expression-evaluation failures that must // surface to callers instead of being treated as literal fallback values. ErrExpressionEvaluationFailed = stderrors.New("cypher: expression evaluation failed") )
var ( // ErrDatabaseQueryTimeLimit ends a statement at its database's query // time limit (multidb query limits). ErrDatabaseQueryTimeLimit error = &statementDeadline{"database query time limit exceeded", TransactionTimedOut, TransactionTimedOutMessage} // ErrServerStatementTimeout ends a Bolt statement at the server's // statement timeout, for a client that set no tx_timeout. ErrServerStatementTimeout error = &statementDeadline{"server statement timeout exceeded", TransactionTimedOut, TransactionTimedOutMessage} // ErrServerTransactionTimeout ends an explicit transaction that stayed // idle for the server's transaction timeout (database.transaction_timeout, // NOR-284): its later statements and COMMIT report it (a statement of the // other transaction type is refused first with ForbiddenDueToTransactionType). ErrServerTransactionTimeout error = &statementDeadline{"server transaction timeout exceeded", TransactionTimedOut, TransactionTimedOutMessage} // ErrClientTransactionTimeout ends a Bolt statement at its client's // tx_timeout. ErrClientTransactionTimeout error = &statementDeadline{"client transaction timeout exceeded", TransactionTimedOutClientConfiguration, TransactionTimedOutClientConfigurationMessage} )
The owned statement deadlines. A deadline installed with any other cause (an embedder's request budget, an inherited HTTP request deadline, a dependency's own timeout) is not a transaction timeout.
var ErrCommitRolledBack = stderrors.New("transaction rolled back at commit")
ErrCommitRolledBack marks a COMMIT failure after which nothing the transaction wrote is stored (the failure was detected before any write), so the outcome is known and the client connection can stay usable.
Functions ¶
func AppendStatusDiagnostics ¶
func AppendStatusDiagnostics(err error, message string, render func(localization.Message) string) string
AppendStatusDiagnostics preserves supplementary failures when a boundary replaces the primary error's message. Ordinary wrapped causes retain their existing formatting. A marked error owns its descriptor and is visited once.
func CombineTerminalOutcomes ¶
CombineTerminalOutcomes is the one composition of a primary failure with its cleanup/rollback failures: the primary stays first, every other cause is retained once, and terminal values compose through the same owner.
func HasNeo4jStatus ¶
HasNeo4jStatus reports whether err carries its own Neo4j status (a status code, a transient transaction failure, a constraint violation or a "Neo." prefix), rather than getting Neo4jStatus's SyntaxError default.
func HasStatusDiagnostic ¶
HasStatusDiagnostic distinguishes a retained diagnostic from ordinary cleanup uncertainty. Protocols keep their existing fatal policy for both outcomes.
func HasTerminalOutcome ¶
HasTerminalOutcome reports an actual owner-produced failed finish value, including wrapped and composed values,without deriving a status from text.
func IsCommitRolledBack ¶
IsCommitRolledBack reports whether a COMMIT failure is known to have kept nothing. Authoritative committed truth in the response overrides a historical child's rollback marker. That child remains reachable through errors.Is for diagnostics, but cannot make an actually committed response retryable.
func IsCompileTimeError ¶
IsCompileTimeError reports a preparation error, including wrapped errors, or an error with a status that always occurs at compile time. Use it when deciding whether a failed HTTP statement has a result shell.
func IsCompileTimeStatus ¶
IsCompileTimeStatus reports whether code is raised while a statement is compiled. A statement failing with any other status compiled, so it has a result with its columns, as Neo4j's HTTP API reports next to the error (#668).
func IsMergeCommitTimeUniqueConflict ¶ added in v1.1.0
IsMergeCommitTimeUniqueConflict reports whether err was explicitly tagged as a retry-safe commit-time UNIQUE violation from a MERGE race.
func IsRetriableStatus ¶
IsRetriableStatus reports whether a Neo4j driver retries a transaction that failed with code: its classification is TransientError, or it is one of the cluster and authorization codes drivers retry (neo4j-go-driver Neo4jError.IsRetriable, which also treats the pre-5.x transient Terminated and LockClientStopped codes as ClientError).
func IsTransientTransactionError ¶
IsTransientTransactionError reports whether err is a transient transaction failure a client may retry. It is the same classification the render pass uses for the failure's status (transientTransactionStatus), without rendering anything (Author: Claude, NOR-180: one classification owner).
func MarkCommitRolledBack ¶
MarkCommitRolledBack tags a COMMIT failure as rolled back (ErrCommitRolledBack) without changing its message. Only the caller that ran the commit knows nothing was written, so it decides.
func MarkCompileTime ¶
MarkCompileTime records that an error occurred during statement preparation. For example, conflicting execution options are ArgumentError at compile time, while invalid function arguments may use the same status at runtime.
func MarkMergeCommitTimeUniqueConflict ¶ added in v1.1.0
MarkMergeCommitTimeUniqueConflict wraps a UNIQUE constraint violation with a dedicated sentinel when the caller knows it came from a retry-safe MERGE commit race (cypher.MergeUniqueConflictIsRetrySafe). Non-UNIQUE failures are returned unchanged.
func MarkStatementTimeout ¶
MarkStatementTimeout marks err, a statement's deadline error, with the status of the owned deadline that ended its context first: cause is context.Cause of the statement's context. Any other cause leaves err as it is. nil stays nil; marking is idempotent.
func Neo4jStatus ¶
Neo4jStatus returns the Neo4j status code and message a client gets for a statement error. Bolt and HTTP both report statement errors through it, so a failure has the same code and message on every protocol:
- an error that carries its code (BoltErrorCode) keeps it;
- transaction conflicts and MVCC pressure are transient (transientTransactionStatus);
- a transaction over the storage size limit is General.TransactionOutOfMemoryError, a ClientError drivers don't retry, with a message saying to split it;
- a statement an owned deadline stopped (MarkStatementTimeout, from its context's cause) is Transaction.TransactionTimedOut, or TransactionTimedOutClientConfiguration for a Bolt client's tx_timeout;
- a constraint violation is Schema.ConstraintValidationFailed;
- a message that starts with (or contains) a "Neo.…: " code keeps that code;
- anything else is Statement.SyntaxError.
The message is the error's text, or its StatusMessage when it has one, and never repeats the code: a leading "<code>: " is removed.
func NormalizeTerminalOutcome ¶
NormalizeTerminalOutcome seals a complete return value at its existing owner boundary before an immediate or deferred consumer receives it. Ordinary errors keep their release behaviour and allocate no terminal value.
func ProjectTerminalOutcomeMessages ¶
ProjectTerminalOutcomeMessages consumes the existing display owner;status, operation,native truth and child identity remain unchanged in the new view.
func RecordCommittedWork ¶
RecordCommittedWork notes, with the enclosing client operation, that native work committed within it. The statement owner publishes every native commit.
func RecordTerminalOutcome ¶
RecordTerminalOutcome records an already-projected statement return with its enclosing client operation. The statement owner decides scope eligibility; this function neither classifies a cause nor starts or ends a transaction.
func RenderStatus ¶
func RenderStatus(err error, render func(localization.Message) string) (code, message string)
RenderStatus renders the immutable outcome at every protocol's existing response boundary. Localization changes display only,not classification.
func RenderStatusWithFallback ¶
func RenderStatusWithFallback(err error, render func(localization.Message) string, classify func(error) (code, message string, ok bool)) (code, message string)
RenderStatusWithFallback preserves a protocol's ordinary-error policies while keeping them outside the already-owned terminal outcome's classification: classify returns ok with the protocol's own status and message for an error it classifies; any other error gets Neo4jStatus's classification.
func TransactionControlFailure ¶
func TransactionControlFailure(op TerminalOperation, err error) error
TransactionControlFailure classifies the failure of a BEGIN, COMMIT, ROLLBACK or post-commit step where that operation produces it: a failure with a status of its own (including a produced terminal outcome) is returned unchanged; an unclassified one takes the operation's status. Every consumer then renders it with the one status renderer, whatever route it takes to the client.
func WithStatus ¶
func WithStatus(cause error, code string, message localization.Message) error
WithStatus records a separate enclosing rejection at its existing policy owner. It never changes a child's already-produced operation or classification.
Types ¶
type Localized ¶ added in v1.3.1
type Localized = localization.LocalizedError
Localized aliases the dependency-neutral localization error carrier.
func NewLocalized ¶ added in v1.3.1
func NewLocalized(code string, message localization.Message, cause error) *Localized
NewLocalized constructs an error that preserves message identity and wrapping.
type TerminalFailure ¶
type TerminalFailure struct {
// contains filtered or unexported fields
}
TerminalFailure owns one failed finish and its immutable classified outcome. Unwrap retains the actual causes for errors.Is/As and existing retry policy.
func NewTerminalFailure ¶
func NewTerminalFailure(operation TerminalOperation, committed bool, primary, terminal error, diagnostic localization.Message) *TerminalFailure
NewTerminalFailure freezes classification and native truth at the logical finish owner. Later cancellation,RESET or aggregation cannot relabel a child. terminal is the failed logical record; it is nil, with an empty diagnostic, for a committed transaction whose record was written but whose post-commit step failed. Every committed outcome is this one value, so composition and retention see its committed truth whether or not its record failed.
func (*TerminalFailure) BoltErrorCode ¶
func (e *TerminalFailure) BoltErrorCode() string
func (*TerminalFailure) Error ¶
func (e *TerminalFailure) Error() string
func (*TerminalFailure) StatusDiagnostic ¶
func (e *TerminalFailure) StatusDiagnostic() localization.Message
StatusDiagnostic retains the existing structural diagnostic contract. The response renderer consumes the complete immutable outcome instead of this leaf.
func (*TerminalFailure) StatusMessage ¶
func (e *TerminalFailure) StatusMessage() string
func (*TerminalFailure) Unwrap ¶
func (e *TerminalFailure) Unwrap() error
type TerminalOperation ¶
type TerminalOperation uint8
TerminalOperation identifies the logical operation whose finish record failed. It is supplied by that operation's owner,never inferred from a later response.
const ( TerminalCommit TerminalOperation = iota TerminalRollback TerminalEmptyCompletion // TerminalAbort ends a transaction because one of its statements failed. // That statement's failure is the primary and keeps its own status. TerminalAbort // TerminalBegin is a transaction's start. TerminalBegin )
type TerminalOutcomeScope ¶
TerminalOutcomeScope is one synchronous client operation's completion owner. It also carries its parent's context, so one allocation installs the scope. Its single state writer publishes immutable TerminalOutcomes snapshots.
func NewTerminalOutcomeScope ¶
func NewTerminalOutcomeScope(ctx context.Context) *TerminalOutcomeScope
NewTerminalOutcomeScope starts an independent client operation. For example, a GraphQL root field can issue several public statements and aggregate counts; Complete must retain their failed terminal records even if a loop drops errors.
func (*TerminalOutcomeScope) Complete ¶
func (s *TerminalOutcomeScope) Complete(primary error) error
Complete returns the operation's primary and every required child outcome.
func (*TerminalOutcomeScope) Value ¶
func (s *TerminalOutcomeScope) Value(key any) any
type TerminalOutcomes ¶
type TerminalOutcomes struct {
// contains filtered or unexported fields
}
TerminalOutcomes is an immutable collection of produced terminal values. Statement and protocol completion owners use the same composition operation; neither an aggregation loop nor a protocol reconstructs a child's status. The zero value is empty. Record returns a new collection when it changes. committed is the owner's own fact that its invocation committed native work, independent of any child's return; Retain gives it to the returned outcome.
func (TerminalOutcomes) Empty ¶
func (o TerminalOutcomes) Empty() bool
Empty reports whether the owner has recorded any failed terminal outcome.
func (TerminalOutcomes) Record ¶
func (o TerminalOutcomes) Record(outcome error) (TerminalOutcomes, bool)
Record retains the complete returned value for each original finish identity. A later display projection replaces its earlier view without changing order, causes, classification or native truth. No published collection is mutated.
func (TerminalOutcomes) RecordCommit ¶
func (o TerminalOutcomes) RecordCommit() (TerminalOutcomes, bool)
RecordCommit notes that the owner's invocation committed native work. It records no failure, so healthy completion is unchanged. It is the only writer of the committed fact.
func (TerminalOutcomes) Retain ¶
func (o TerminalOutcomes) Retain(primary error) error
Retain composes the primary return and every recorded immutable outcome. Healthy completion keeps the original result/error contract.