-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy patherrors.go
More file actions
55 lines (46 loc) · 1.56 KB
/
errors.go
File metadata and controls
55 lines (46 loc) · 1.56 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
//nolint:revive,gocritic,unused
package schema
import (
"fmt"
"github.com/apache/arrow-go/v18/arrow"
)
const (
noConversion = "no conversion available"
cannotDecodeString = "cannot decode from string"
cannotFindDimensions = "cannot find dimensions"
notInterface = "not an interface"
expectedElements = "expected %d elements, but got %d instead"
expectedElementsInDimension = "expected %d elements in dimension %d, but got %d instead"
cannotSetIndex = "cannot set index %d"
)
// PatternMatchError is returned by Tables.FilterDfs when a tables or skip_tables
// pattern does not match any known table.
type PatternMatchError struct {
Key string // "tables" or "skip_tables"
Pattern string // the glob pattern that had no matches
}
func (e *PatternMatchError) Error() string {
return fmt.Sprintf("%s include a pattern %s with no matches", e.Key, e.Pattern)
}
type ValidationError struct {
Err error
Msg string
Type arrow.DataType
Value any
}
func (e *ValidationError) Error() string {
if e.Err == nil {
return fmt.Sprintf("cannot set `%s` with value `%v`: %s", e.Type, e.Value, e.Msg)
}
return fmt.Sprintf("cannot set `%s` with value `%v`: %s (%s)", e.Type, e.Value, e.Msg, e.Err)
}
// this prints the error without the value
func (e *ValidationError) MaskedError() string {
if e.Err == nil {
return fmt.Sprintf("cannot set `%s`: %s", e.Type, e.Msg)
}
return fmt.Sprintf("cannot set `%s`: %s (%s)", e.Type, e.Msg, e.Err)
}
func (e *ValidationError) Unwrap() error {
return e.Err
}