errors

package
v1.4.0-preview-1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

Index

Constants

View Source
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"
	// 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"
)
View Source
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"
	// TransactionCommitFailed is the status of a COMMIT that failed for a
	// reason with no more specific classification.
	TransactionCommitFailed = "Neo.ClientError.Transaction.TransactionCommitFailed"
)

Variables

View Source
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 marks lock-ordering deadlocks that drivers should
	// retry as Neo4j-compatible transient transaction failures.
	ErrTransactionDeadlock = stderrors.New("transaction deadlock")
	// 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")
)
View Source
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 HasNeo4jStatus

func HasNeo4jStatus(err error) bool

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 IsCommitRolledBack

func IsCommitRolledBack(err error) bool

IsCommitRolledBack reports whether a COMMIT failure was tagged by MarkCommitRolledBack.

func IsCompileTimeStatus

func IsCompileTimeStatus(code string) bool

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

func IsMergeCommitTimeUniqueConflict(err error) bool

IsMergeCommitTimeUniqueConflict reports whether err was explicitly tagged as a retry-safe commit-time UNIQUE violation from a MERGE race.

func MapTransientTransactionError

func MapTransientTransactionError(err error) (string, bool)

MapTransientTransactionError maps known transaction failure sentinels to Neo4j-compatible transient transaction codes. It intentionally classifies by error reference rather than message text so localized or templated messages do not change retry semantics.

func MarkCommitRolledBack

func MarkCommitRolledBack(err error) error

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 MarkMergeCommitTimeUniqueConflict added in v1.1.0

func MarkMergeCommitTimeUniqueConflict(err error) error

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 Neo4jCommitStatus

func Neo4jCommitStatus(err error) (code, message string)

Neo4jCommitStatus is Neo4jStatus for a failed COMMIT: a failure with no more specific classification is Transaction.TransactionCommitFailed.

func Neo4jStatus

func Neo4jStatus(err error) (code, message string)

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 (MapTransientTransactionError);
  • a transaction over the storage size limit is General.TransactionOutOfMemoryError, a ClientError drivers don't retry, with a message saying to split it;
  • 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.

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.

Jump to

Keyboard shortcuts

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