-
Notifications
You must be signed in to change notification settings - Fork 10
/
errors.go
54 lines (43 loc) · 983 Bytes
/
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
45
46
47
48
49
50
51
52
53
54
package idl
import (
"fmt"
)
type DecodeError struct {
Types TupleType
Description string
}
func (e DecodeError) Error() string {
return fmt.Sprintf("%s %s", e.Types.String(), e.Description)
}
type EncodeValueError struct {
Expected int64
Value any
}
func NewEncodeValueError(v any, e int64) *EncodeValueError {
return &EncodeValueError{
Expected: e,
Value: v,
}
}
func (e EncodeValueError) Error() string {
return fmt.Sprintf("invalid type %v (%T), expected type %s", e.Value, e.Value, idlString(e.Expected))
}
type FormatError struct {
Description string
}
func (e FormatError) Error() string {
return fmt.Sprintf("() %s", e.Description)
}
type UnmarshalGoError struct {
Raw any
V any
}
func NewUnmarshalGoError(raw any, v any) *UnmarshalGoError {
return &UnmarshalGoError{
Raw: raw,
V: v,
}
}
func (e UnmarshalGoError) Error() string {
return fmt.Sprintf("cannot unmarshal %v (%T) into Go value of type %T", e.Raw, e.Raw, e.V)
}