-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrs.go
More file actions
56 lines (46 loc) · 1.76 KB
/
Copy patherrs.go
File metadata and controls
56 lines (46 loc) · 1.76 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
package codec
import (
"fmt"
"reflect"
com "github.com/mus-format/common-go"
)
// NewUnrecognizedType returns an error indicating that an unsupported type
// was encountered during encoding.
func NewUnrecognizedType(t reflect.Type) error {
return fmt.Errorf("unrecognized type: %T", t)
}
// NewFailedToMarshalDTM returns an error indicating that the data type marker
// (DTM) could not be marshaled.
func NewFailedToMarshalDTM(err error) error {
return fmt.Errorf("failed to marshal DTM: %w", err)
}
// NewFailedToMarshalValue returns an error indicating that value marshaling
// failed.
func NewFailedToMarshalValue(value any, cause error) error {
return fmt.Errorf("failed to marshal %T value: %w", value, cause)
}
// NewFailedToMarshalByteSlice returns an error indicating that a byte slice
// could not be marshaled.
func NewFailedToMarshalByteSlice(err error) error {
return fmt.Errorf("failed to marshal byte slice: %w", err)
}
// NewFailedToUnmarshalDTM returns an error indicating that the data type
// marker (DTM) could not be unmarshaled.
func NewFailedToUnmarshalDTM(err error) error {
return fmt.Errorf("failed to unmarshal DTM: %w", err)
}
// NewUnrecognizedDTM returns an error indicating that an unknown data type
// marker (DTM) was received.
func NewUnrecognizedDTM(dtm com.DTM) error {
return fmt.Errorf("unrecognized DTM: %v", dtm)
}
// NewFailedToUnmarshalByteSlice returns an error indicating that a byte slice
// could not be unmarshaled.
func NewFailedToUnmarshalByteSlice(err error) error {
return fmt.Errorf("failed to unmarshal byte slice: %w", err)
}
// NewFailedToUnmarshalValue returns an error indicating that value
// unmarshaling failed.
func NewFailedToUnmarshalValue(err error) error {
return fmt.Errorf("failed to unmarshal value: %w", err)
}