errors

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errors provides standardized error types for DataFrame operations. This package defines DataFrameError for consistent error handling across all public APIs, with operation context and error wrapping support.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyDataFrame indicates operations on empty DataFrames
	ErrEmptyDataFrame = &DataFrameError{
		Op:      "validation",
		Message: "operation not supported on empty DataFrame",
	}

	// ErrMismatchedLength indicates length mismatches in operations
	ErrMismatchedLength = &DataFrameError{
		Op:      "validation",
		Message: "arrays must have the same length",
	}

	// ErrInvalidIndex indicates out-of-bounds index access
	ErrInvalidIndex = &DataFrameError{
		Op:      "indexing",
		Message: "index out of bounds",
	}
)

Predefined error variables for common cases

Functions

This section is empty.

Types

type DataFrameError

type DataFrameError struct {
	Op       string            // Operation name (e.g., "Sort", "Filter", "Join")
	Column   string            // Column name if applicable
	Message  string            // Human-readable error description
	Cause    error             // Underlying error cause
	Hint     string            // Suggested solution or helpful tip
	Context  map[string]string // Additional context information
	DataInfo *DataFrameInfo    // DataFrame information for better context
}

DataFrameError represents standardized errors across all DataFrame operations

func NewColumnNotFoundError

func NewColumnNotFoundError(op, column string) *DataFrameError

NewColumnNotFoundError creates an error for operations on non-existent columns

func NewColumnNotFoundErrorWithSuggestions

func NewColumnNotFoundErrorWithSuggestions(op, column string, availableColumns []string) *DataFrameError

NewColumnNotFoundErrorWithSuggestions creates a column not found error with similar column suggestions

func NewIndexOutOfBoundsError

func NewIndexOutOfBoundsError(op string, index, maxIndex int) *DataFrameError

NewIndexOutOfBoundsError creates an error for out-of-bounds index access

func NewInternalError

func NewInternalError(op string, cause error) *DataFrameError

NewInternalError creates an error for internal operation failures

func NewInvalidInputError

func NewInvalidInputError(op, message string) *DataFrameError

NewInvalidInputError creates an error for invalid operation inputs

func NewTypeMismatchError

func NewTypeMismatchError(op, column, expectedType, actualType string) *DataFrameError

NewTypeMismatchError creates an error for type mismatches

func NewUnsupportedTypeError

func NewUnsupportedTypeError(op, typeName string) *DataFrameError

NewUnsupportedTypeError creates an error for unsupported data types

func NewValidationError

func NewValidationError(op, column, message string) *DataFrameError

NewValidationError creates an error for input validation failures

func (*DataFrameError) Error

func (e *DataFrameError) Error() string

Error implements the error interface

func (*DataFrameError) Format

func (e *DataFrameError) Format(level ErrorLevel) string

Format returns a formatted error message at the specified verbosity level

func (*DataFrameError) Is

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

Is implements error equality checking for errors.Is()

func (*DataFrameError) Unwrap

func (e *DataFrameError) Unwrap() error

Unwrap returns the underlying cause for error wrapping support

func (*DataFrameError) WithCause

func (e *DataFrameError) WithCause(cause error) *DataFrameError

WithCause adds an underlying cause to the error

func (*DataFrameError) WithContext

func (e *DataFrameError) WithContext(context map[string]string) *DataFrameError

WithContext adds additional context information to the error

func (*DataFrameError) WithDataFrameInfo

func (e *DataFrameError) WithDataFrameInfo(info DataFrameInfo) *DataFrameError

WithDataFrameInfo adds DataFrame information for better context

func (*DataFrameError) WithHint

func (e *DataFrameError) WithHint(hint string) *DataFrameError

WithHint adds a helpful hint to the error

type DataFrameInfo

type DataFrameInfo struct {
	Rows    int               // Number of rows
	Columns []string          // Column names
	Types   map[string]string // Column name to type mapping
}

DataFrameInfo contains information about a DataFrame for error context

type ErrorLevel

type ErrorLevel int

ErrorLevel defines the verbosity level for error formatting

const (
	ErrorLevelSimple ErrorLevel = iota
	ErrorLevelDetailed
	ErrorLevelDebug
)

type OperationContext

type OperationContext struct {
	Operation  string        // High-level operation name
	Step       int           // Current step number
	TotalSteps int           // Total number of steps
	DataInfo   DataFrameInfo // Information about the DataFrame being processed
}

OperationContext provides context for wrapping errors in multi-step operations

func (*OperationContext) WrapError

func (ctx *OperationContext) WrapError(err error) *DataFrameError

WrapError wraps an error with operation context information

Jump to

Keyboard shortcuts

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