-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
79 lines (64 loc) · 2.02 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
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
package transport
import (
"errors"
"fmt"
"reflect"
)
var (
ErrDestinationNotPointer = errors.New("destination for value is not a pointer")
ErrDestinationNotStruct = errors.New("destination for value is not a struct")
ErrDestinationIsNil = errors.New("destination for value is nil")
ErrSourceNotPointer = errors.New("source for value is not a pointer")
ErrSourceNotStruct = errors.New("source for value is not a struct")
ErrSourceIsNil = errors.New("source for value is nil")
ErrMessageScannerNoData = errors.New("message scanner has not data")
ErrMessageHeaderNotFound = errors.New("message header not found")
ErrMessageHeaderMalformed = errors.New("message header malformed")
ErrFieldEntryInvalid = errors.New("header field entry is invalid")
ErrFieldsEmpty = errors.New("header fields are empty")
ErrInvalidConfigurationItem = errors.New("configuration item is invalid")
ErrEmptyInformationalMessage = errors.New("informational message is empty")
ErrNotImplemented = errors.New("not implemented")
)
// MessageMarshalerError is used when performing automatic reflection-based
// marhsalling into a message.
type MessageMarshalerError struct {
Type reflect.Type
Err error
source string
}
// FieldMarshalerError is used when performing automatic reflection-based
// marshaling into a field.
type FieldMarshalerError struct {
Type reflect.Type
Err error
source string
}
func (err *FieldMarshalerError) Error() string {
source := err.source
if source == "" {
source = "MarshalFields"
}
return fmt.Sprintf(
"apt/transport: error calling %q for type %q: %s",
source,
err.Type.String(),
err.Err.Error())
}
func (err *FieldMarshalerError) Unwrap() error {
return err.Err
}
func (err *MessageMarshalerError) Error() string {
source := err.source
if source == "" {
source = "MarshalMessage"
}
return fmt.Sprintf(
"apt/transport: error calling %q for type %q: %s",
source,
err.Type.String(),
err.Err.Error())
}
func (err *MessageMarshalerError) Unwrap() error {
return err.Err
}