-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
187 lines (154 loc) · 5.18 KB
/
errors.go
File metadata and controls
187 lines (154 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package goiceberg
import (
"errors"
"fmt"
"time"
)
// Common errors for go-iceberg operations.
var (
// Table errors
ErrTableNotFound = errors.New("table not found")
ErrTableAlreadyExists = errors.New("table already exists")
// Namespace errors
ErrNamespaceNotFound = errors.New("namespace not found")
ErrNamespaceAlreadyExists = errors.New("namespace already exists")
ErrNamespaceNotEmpty = errors.New("namespace is not empty")
// Transaction errors
ErrTransactionClosed = errors.New("transaction already committed or aborted")
ErrCommitConflict = errors.New("commit conflict: table was modified")
ErrRequirementFailed = errors.New("commit requirement failed")
ErrNoChangesToCommit = errors.New("no changes to commit")
// Schema errors
ErrSchemaNotCompatible = errors.New("schema is not compatible")
ErrColumnNotFound = errors.New("column not found")
ErrInvalidSchema = errors.New("invalid schema")
// Snapshot errors
ErrSnapshotNotFound = errors.New("snapshot not found")
ErrNoCurrentSnapshot = errors.New("table has no current snapshot")
// Data errors
ErrInvalidData = errors.New("invalid data format")
ErrTypeMismatch = errors.New("type mismatch")
ErrInvalidFilter = errors.New("invalid filter expression")
// IO errors
ErrFileNotFound = errors.New("file not found")
ErrIOFailed = errors.New("IO operation failed")
ErrInvalidPath = errors.New("invalid file path")
// Catalog errors
ErrCatalogNotConfigured = errors.New("catalog not configured")
ErrAuthenticationFailed = errors.New("authentication failed")
// Configuration errors
ErrInvalidConfig = errors.New("invalid configuration")
)
// CommitConflictError represents a commit conflict with details.
type CommitConflictError struct {
TableIdentifier string
ExpectedVersion int64
ActualVersion int64
Cause error
}
// Error implements the error interface.
func (e *CommitConflictError) Error() string {
return fmt.Sprintf("commit conflict on table %s: expected version %d, actual version %d",
e.TableIdentifier, e.ExpectedVersion, e.ActualVersion)
}
// Unwrap returns the underlying cause.
func (e *CommitConflictError) Unwrap() error {
return e.Cause
}
// Is reports whether the target matches this error.
func (e *CommitConflictError) Is(target error) bool {
return target == ErrCommitConflict
}
// RequirementError represents a failed commit requirement.
type RequirementError struct {
Requirement string
Expected any
Actual any
}
// Error implements the error interface.
func (e *RequirementError) Error() string {
return fmt.Sprintf("requirement failed: %s (expected: %v, actual: %v)",
e.Requirement, e.Expected, e.Actual)
}
// Is reports whether the target matches this error.
func (e *RequirementError) Is(target error) bool {
return target == ErrRequirementFailed
}
// RetryableError wraps an error that can be retried.
type RetryableError struct {
Cause error
RetryAfter time.Duration
}
// Error implements the error interface.
func (e *RetryableError) Error() string {
if e.RetryAfter > 0 {
return fmt.Sprintf("retryable error (retry after %v): %v", e.RetryAfter, e.Cause)
}
return fmt.Sprintf("retryable error: %v", e.Cause)
}
// Unwrap returns the underlying cause.
func (e *RetryableError) Unwrap() error {
return e.Cause
}
// IsRetryable reports whether the error can be retried.
func IsRetryable(err error) bool {
var retryable *RetryableError
if errors.As(err, &retryable) {
return true
}
// Commit conflicts are retryable
var conflict *CommitConflictError
return errors.As(err, &conflict)
}
// TableNotFoundError represents a table not found error with details.
type TableNotFoundError struct {
Namespace string
TableName string
}
// Error implements the error interface.
func (e *TableNotFoundError) Error() string {
return fmt.Sprintf("table not found: %s.%s", e.Namespace, e.TableName)
}
// Is reports whether the target matches this error.
func (e *TableNotFoundError) Is(target error) bool {
return target == ErrTableNotFound
}
// NamespaceNotFoundError represents a namespace not found error with details.
type NamespaceNotFoundError struct {
Namespace string
}
// Error implements the error interface.
func (e *NamespaceNotFoundError) Error() string {
return fmt.Sprintf("namespace not found: %s", e.Namespace)
}
// Is reports whether the target matches this error.
func (e *NamespaceNotFoundError) Is(target error) bool {
return target == ErrNamespaceNotFound
}
// ValidationError represents a validation error.
type ValidationError struct {
Field string
Message string
}
// Error implements the error interface.
func (e *ValidationError) Error() string {
return fmt.Sprintf("validation error on %s: %s", e.Field, e.Message)
}
// IOError represents an IO error with path information.
type IOError struct {
Operation string
Path string
Cause error
}
// Error implements the error interface.
func (e *IOError) Error() string {
return fmt.Sprintf("IO error during %s on %s: %v", e.Operation, e.Path, e.Cause)
}
// Unwrap returns the underlying cause.
func (e *IOError) Unwrap() error {
return e.Cause
}
// Is reports whether the target matches this error.
func (e *IOError) Is(target error) bool {
return target == ErrIOFailed
}