errors

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package errors defines error types and utilities for DynamORM

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrItemNotFound is returned when an item is not found in the database
	ErrItemNotFound = errors.New("item not found")

	// ErrInvalidModel is returned when a model struct is invalid
	ErrInvalidModel = errors.New("invalid model")

	// ErrMissingPrimaryKey is returned when a model doesn't have a primary key
	ErrMissingPrimaryKey = errors.New("missing primary key")

	// ErrInvalidPrimaryKey is returned when a primary key value is invalid
	ErrInvalidPrimaryKey = errors.New("invalid primary key")

	// ErrConditionFailed is returned when a condition check fails
	ErrConditionFailed = errors.New("condition check failed")

	// ErrIndexNotFound is returned when a specified index doesn't exist
	ErrIndexNotFound = errors.New("index not found")

	// ErrTransactionFailed is returned when a transaction fails
	ErrTransactionFailed = errors.New("transaction failed")

	// ErrBatchOperationFailed is returned when a batch operation partially fails
	ErrBatchOperationFailed = errors.New("batch operation failed")

	// ErrUnsupportedType is returned when a field type is not supported
	ErrUnsupportedType = errors.New("unsupported type")

	// ErrInvalidTag is returned when a struct tag is invalid
	ErrInvalidTag = errors.New("invalid struct tag")

	// ErrTableNotFound is returned when a table doesn't exist
	ErrTableNotFound = errors.New("table not found")

	// ErrDuplicatePrimaryKey is returned when multiple primary keys are defined
	ErrDuplicatePrimaryKey = errors.New("duplicate primary key definition")

	// ErrEmptyValue is returned when a required value is empty
	ErrEmptyValue = errors.New("empty value")

	// ErrInvalidOperator is returned when an invalid query operator is used
	ErrInvalidOperator = errors.New("invalid query operator")
)

Common errors that can occur in DynamORM operations

Functions

func IsConditionFailed

func IsConditionFailed(err error) bool

IsConditionFailed checks if an error indicates a condition check failure

func IsInvalidModel

func IsInvalidModel(err error) bool

IsInvalidModel checks if an error indicates an invalid model

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error indicates an item was not found

Types

type DynamORMError

type DynamORMError struct {
	Op      string         // Operation that failed
	Model   string         // Model type name
	Err     error          // Underlying error
	Context map[string]any // Additional context
}

DynamORMError represents a detailed error with context

func NewError

func NewError(op, model string, err error) *DynamORMError

NewError creates a new DynamORMError

func NewErrorWithContext

func NewErrorWithContext(op, model string, err error, context map[string]any) *DynamORMError

NewErrorWithContext creates a new DynamORMError with context

func (*DynamORMError) Error

func (e *DynamORMError) Error() string

Error implements the error interface

func (*DynamORMError) Is

func (e *DynamORMError) Is(target error) bool

Is checks if the error matches the target error

func (*DynamORMError) Unwrap

func (e *DynamORMError) Unwrap() error

Unwrap returns the underlying error

Jump to

Keyboard shortcuts

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