-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
50 lines (36 loc) · 1.03 KB
/
error.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
package msgpack
import "fmt"
const errLengthLimitExceeded = errorString("length limit exceeded")
type errorString string
func errorf(format string, args ...interface{}) error {
return errorString(fmt.Sprintf(format, args...))
}
func (e errorString) Error() string {
return string(e)
}
// TypeError specifies an error type for unexpected wire types.
type TypeError struct {
Actual Type
Expected Type
}
// Error returns the error message of the error.
func (e TypeError) Error() string {
return "unexpected type: " + string(e.Actual) + " (expected " + string(e.Expected) + ")"
}
type intOverflowError struct{}
func (e intOverflowError) Error() string {
return "integer overflow"
}
type floatOverflowError struct{}
func (e floatOverflowError) Error() string {
return "floating-point overflow"
}
type invalidExtensionError struct {
typ int8
}
func newInvalidExtensionError(typ int8) error {
return invalidExtensionError{typ}
}
func (e invalidExtensionError) Error() string {
return fmt.Sprintf("invalid extension type %d", e.typ)
}