Documentation
¶
Index ¶
- type Category
- type ErrorCode
- type ErrorCollector
- func (ec *ErrorCollector) AddError(err *StructuredError)
- func (ec *ErrorCollector) Clear()
- func (ec *ErrorCollector) GetAllIssues() []*StructuredError
- func (ec *ErrorCollector) GetErrors() []*StructuredError
- func (ec *ErrorCollector) GetWarnings() []*StructuredError
- func (ec *ErrorCollector) HasErrors() bool
- func (ec *ErrorCollector) HasWarnings() bool
- func (ec *ErrorCollector) Summary() ErrorSummary
- type ErrorContext
- type ErrorFormatter
- type ErrorSummary
- type Severity
- type StructuredError
- func New(code ErrorCode, category Category, message string, additional map[string]any) *StructuredError
- func NewCriticalError(code ErrorCode, message string, category Category) *StructuredError
- func NewError(code ErrorCode, message string, severity Severity, category Category) *StructuredError
- func NewNormalizationError(message string, index int) *StructuredError
- func NewParseError(code ErrorCode, message string) *StructuredError
- func NewTransformationError(code ErrorCode, message string) *StructuredError
- func NewTypeError(code ErrorCode, message string, typeName string) *StructuredError
- func NewValidationError(code ErrorCode, message string) *StructuredError
- func NewWarning(category Category, message string) *StructuredError
- func Wrap(innerErr error, code ErrorCode, category Category, message string, ...) *StructuredError
- func (e *StructuredError) Error() string
- func (e *StructuredError) Unwrap() error
- func (e *StructuredError) WithAdditional(key string, value any) *StructuredError
- func (e *StructuredError) WithCanContinue(canContinue bool) *StructuredError
- func (e *StructuredError) WithColumn(column int) *StructuredError
- func (e *StructuredError) WithContext(ctx *ErrorContext) *StructuredError
- func (e *StructuredError) WithFile(filename string) *StructuredError
- func (e *StructuredError) WithInnerError(err error) *StructuredError
- func (e *StructuredError) WithLine(line int) *StructuredError
- func (e *StructuredError) WithObject(name, objType string) *StructuredError
- func (e *StructuredError) WithSQLQuery(query string) *StructuredError
- func (e *StructuredError) WithSchema(schema string) *StructuredError
- func (e *StructuredError) WithStatement(sql string) *StructuredError
- func (e *StructuredError) WithSuggestion(suggestion string) *StructuredError
- func (e *StructuredError) WithTypeName(typeName string) *StructuredError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category string
Category represents the category of errors and warnings.
const ( // Core error categories CategorySyntax Category = "SYNTAX" CategorySemantic Category = "SEMANTIC" CategoryDependency Category = "DEPENDENCY" CategoryNaming Category = "NAMING" CategoryPermission Category = "PERMISSION" CategoryConstraint Category = "CONSTRAINT" CategoryDataType Category = "DATA_TYPE" CategoryFunction Category = "FUNCTION" CategoryIndex Category = "INDEX" CategoryPolicy Category = "POLICY" CategoryExtension Category = "EXTENSION" CategoryPerformance Category = "PERFORMANCE" CategoryValidation Category = "VALIDATION" CategoryTransformation Category = "TRANSFORMATION" CategoryType Category = "TYPE" CategoryNormalization Category = "NORMALIZATION" CategoryParsing Category = "PARSING" CategoryConsolidation Category = "CONSOLIDATION" // Additional categories from WarningManager CategoryCycle Category = "CYCLE" CategoryOptimization Category = "OPTIMIZATION" CategoryRisk Category = "RISK" CategoryBackup Category = "BACKUP" CategoryRollback Category = "ROLLBACK" CategoryInfo Category = "INFO" CategoryGeneral Category = "GENERAL" )
type ErrorCode ¶
type ErrorCode string
ErrorCode represents specific error codes
const ( // Parse errors ErrorCodeSyntaxError ErrorCode = "SYNTAX_ERROR" ErrorCodeSemanticError ErrorCode = "SEMANTIC_ERROR" ErrorCodeDependencyError ErrorCode = "DEPENDENCY_ERROR" // Validation errors ErrorCodeValidationFailed ErrorCode = "VALIDATION_FAILED" ErrorCodeSchemaNotFound ErrorCode = "SCHEMA_NOT_FOUND" ErrorCodeInvalidObject ErrorCode = "INVALID_OBJECT" // Transformation errors ErrorCodeRollbackGenerationFailed ErrorCode = "ROLLBACK_GENERATION_FAILED" ErrorCodeRollbackAnalysisFailed ErrorCode = "ROLLBACK_ANALYSIS_FAILED" ErrorCodeRollbackSaveFailed ErrorCode = "ROLLBACK_SAVE_FAILED" ErrorCodeRollbackNotFound ErrorCode = "ROLLBACK_NOT_FOUND" ErrorCodeExecutionNotFound ErrorCode = "EXECUTION_NOT_FOUND" ErrorCodeDatabaseNotAccessible ErrorCode = "DATABASE_NOT_ACCESSIBLE" ErrorCodeManualInterventionRequired ErrorCode = "MANUAL_INTERVENTION_REQUIRED" ErrorCodeInvalidSQL ErrorCode = "INVALID_SQL" ErrorCodeBackupGenerationFailed ErrorCode = "BACKUP_GENERATION_FAILED" ErrorCodeBackupValidationFailed ErrorCode = "BACKUP_VALIDATION_FAILED" ErrorCodeTransformationFailed ErrorCode = "TRANSFORMATION_FAILED" ErrorCodeWorkingDirCreationFailed ErrorCode = "WORKING_DIR_CREATION_FAILED" // Type errors ErrorCodeInvalidType ErrorCode = "INVALID_TYPE" ErrorCodeTypeNotFound ErrorCode = "TYPE_NOT_FOUND" ErrorCodeIncompatibleTypes ErrorCode = "INCOMPATIBLE_TYPES" ErrorCodeArraySpecError ErrorCode = "ARRAY_SPEC_ERROR" ErrorCodeSizeExtractionError ErrorCode = "SIZE_EXTRACTION_ERROR" ErrorCodeEnumValidationError ErrorCode = "ENUM_VALIDATION_ERROR" ErrorCodeCompositeTypeError ErrorCode = "COMPOSITE_TYPE_ERROR" ErrorCodeAnalysisError ErrorCode = "ANALYSIS_ERROR" ErrorCodeConfigurationError ErrorCode = "CONFIGURATION_ERROR" // Consolidation errors ErrorCodeConsolidationFailed ErrorCode = "CONSOLIDATION_FAILED" ErrorCodeSQLGenerationFailed ErrorCode = "SQL_GENERATION_FAILED" ErrorCodeRecoveryAttempted ErrorCode = "RECOVERY_ATTEMPTED" ErrorCodePartialSuccess ErrorCode = "PARTIAL_SUCCESS" // Normalization errors ErrorCodeNormalizationFailed ErrorCode = "NORMALIZATION_FAILED" ErrorCodeInvalidIdentifier ErrorCode = "INVALID_IDENTIFIER" )
Common error codes
type ErrorCollector ¶
type ErrorCollector struct {
// contains filtered or unexported fields
}
ErrorCollector collects and manages errors
func NewErrorCollector ¶
func NewErrorCollector(ctx context.Context) *ErrorCollector
NewErrorCollector creates a new error collector
func (*ErrorCollector) AddError ¶
func (ec *ErrorCollector) AddError(err *StructuredError)
AddError adds an error to the collector
func (*ErrorCollector) Clear ¶
func (ec *ErrorCollector) Clear()
Clear removes all collected errors and warnings
func (*ErrorCollector) GetAllIssues ¶
func (ec *ErrorCollector) GetAllIssues() []*StructuredError
GetAllIssues returns both errors and warnings
func (*ErrorCollector) GetErrors ¶
func (ec *ErrorCollector) GetErrors() []*StructuredError
GetErrors returns all errors
func (*ErrorCollector) GetWarnings ¶
func (ec *ErrorCollector) GetWarnings() []*StructuredError
GetWarnings returns all warnings
func (*ErrorCollector) HasErrors ¶
func (ec *ErrorCollector) HasErrors() bool
HasErrors returns true if there are any errors
func (*ErrorCollector) HasWarnings ¶
func (ec *ErrorCollector) HasWarnings() bool
HasWarnings returns true if there are any warnings
func (*ErrorCollector) Summary ¶
func (ec *ErrorCollector) Summary() ErrorSummary
Summary returns a summary of collected issues
type ErrorContext ¶
type ErrorContext struct {
Filename string `json:"filename,omitempty"`
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
ObjectName string `json:"object_name,omitempty"`
ObjectType string `json:"object_type,omitempty"`
Schema string `json:"schema,omitempty"`
StatementText string `json:"statement_text,omitempty"`
MigrationSeq int `json:"migration_seq,omitempty"`
ProcessingPhase string `json:"processing_phase,omitempty"`
TypeName string `json:"type_name,omitempty"`
SQLQuery string `json:"sql_query,omitempty"`
Additional map[string]any `json:"additional,omitempty"`
}
ErrorContext provides context information for errors
type ErrorFormatter ¶
type ErrorFormatter struct{}
ErrorFormatter formats errors for different outputs
func NewErrorFormatter ¶
func NewErrorFormatter() *ErrorFormatter
NewErrorFormatter creates a new error formatter
func (*ErrorFormatter) FormatError ¶
func (ef *ErrorFormatter) FormatError(err *StructuredError) string
FormatError formats a single error
func (*ErrorFormatter) FormatErrorList ¶
func (ef *ErrorFormatter) FormatErrorList(errors []*StructuredError) string
FormatErrorList formats a list of errors
func (*ErrorFormatter) FormatSummary ¶
func (ef *ErrorFormatter) FormatSummary(summary ErrorSummary) string
FormatSummary formats an error summary
type ErrorSummary ¶
type ErrorSummary struct {
TotalErrors int
TotalWarnings int
Categories map[Category]int
Severities map[Severity]int
Codes map[ErrorCode]int
}
ErrorSummary provides a summary of collected errors
type StructuredError ¶
type StructuredError struct {
Code ErrorCode `json:"code"`
Message string `json:"message"`
Severity Severity `json:"severity"`
Category Category `json:"category"`
Context *ErrorContext `json:"context,omitempty"`
Suggestion string `json:"suggestion,omitempty"`
InnerError error `json:"-"`
CanContinue bool `json:"can_continue"`
}
StructuredError is a unified error type for all pgsquash errors
func New ¶
func New(code ErrorCode, category Category, message string, additional map[string]any) *StructuredError
New creates a new StructuredError with additional context (convenience function)
func NewCriticalError ¶
func NewCriticalError(code ErrorCode, message string, category Category) *StructuredError
NewCriticalError creates a critical error
func NewError ¶
func NewError(code ErrorCode, message string, severity Severity, category Category) *StructuredError
NewError creates a new StructuredError
func NewNormalizationError ¶
func NewNormalizationError(message string, index int) *StructuredError
NewNormalizationError creates a normalization error
func NewParseError ¶
func NewParseError(code ErrorCode, message string) *StructuredError
NewParseError creates a parse error
func NewTransformationError ¶
func NewTransformationError(code ErrorCode, message string) *StructuredError
NewTransformationError creates a transformation error
func NewTypeError ¶
func NewTypeError(code ErrorCode, message string, typeName string) *StructuredError
NewTypeError creates a type error
func NewValidationError ¶
func NewValidationError(code ErrorCode, message string) *StructuredError
NewValidationError creates a validation error
func NewWarning ¶
func NewWarning(category Category, message string) *StructuredError
NewWarning creates a warning
func Wrap ¶
func Wrap(innerErr error, code ErrorCode, category Category, message string, additional map[string]any) *StructuredError
Wrap wraps an existing error with structured error context (convenience function)
func (*StructuredError) Error ¶
func (e *StructuredError) Error() string
Error implements the error interface
func (*StructuredError) Unwrap ¶
func (e *StructuredError) Unwrap() error
Unwrap returns the inner error for error unwrapping
func (*StructuredError) WithAdditional ¶
func (e *StructuredError) WithAdditional(key string, value any) *StructuredError
WithAdditional adds additional context
func (*StructuredError) WithCanContinue ¶
func (e *StructuredError) WithCanContinue(canContinue bool) *StructuredError
WithCanContinue sets whether processing can continue
func (*StructuredError) WithColumn ¶
func (e *StructuredError) WithColumn(column int) *StructuredError
WithColumn sets the column number
func (*StructuredError) WithContext ¶
func (e *StructuredError) WithContext(ctx *ErrorContext) *StructuredError
WithContext sets the error context
func (*StructuredError) WithFile ¶
func (e *StructuredError) WithFile(filename string) *StructuredError
WithFile sets the filename
func (*StructuredError) WithInnerError ¶
func (e *StructuredError) WithInnerError(err error) *StructuredError
WithInnerError wraps an inner error
func (*StructuredError) WithLine ¶
func (e *StructuredError) WithLine(line int) *StructuredError
WithLine sets the line number
func (*StructuredError) WithObject ¶
func (e *StructuredError) WithObject(name, objType string) *StructuredError
WithObject sets the object name and type
func (*StructuredError) WithSQLQuery ¶
func (e *StructuredError) WithSQLQuery(query string) *StructuredError
WithSQLQuery sets the SQL query
func (*StructuredError) WithSchema ¶
func (e *StructuredError) WithSchema(schema string) *StructuredError
WithSchema sets the schema
func (*StructuredError) WithStatement ¶
func (e *StructuredError) WithStatement(sql string) *StructuredError
WithStatement sets the statement text
func (*StructuredError) WithSuggestion ¶
func (e *StructuredError) WithSuggestion(suggestion string) *StructuredError
WithSuggestion adds a suggestion
func (*StructuredError) WithTypeName ¶
func (e *StructuredError) WithTypeName(typeName string) *StructuredError
WithTypeName sets the type name