-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy patherrors.go
44 lines (37 loc) · 1.17 KB
/
errors.go
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
//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"
)
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
}