-
Notifications
You must be signed in to change notification settings - Fork 4
/
err.go
38 lines (31 loc) · 1.19 KB
/
err.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
package surge
import (
"errors"
"fmt"
)
// ErrUnexpectedEndOfBuffer is used when reading/writing from/to a buffer that
// has less space than expected.
var ErrUnexpectedEndOfBuffer = errors.New("unexpected end of buffer")
// ErrLengthOverflow is returned when the length of an array or slice has
// overflowed.
var ErrLengthOverflow = errors.New("max bytes exceeded")
// ErrUnsupportedMarshalType is returned when the an unsupported type is
// encountered during marshaling.
type ErrUnsupportedMarshalType struct {
error
}
// NewErrUnsupportedMarshalType constructs a new unsupported marshal type error
// for the given type.
func NewErrUnsupportedMarshalType(v interface{}) error {
return ErrUnsupportedMarshalType{error: fmt.Errorf("marshal error: unsupported type %T", v)}
}
// ErrUnsupportedUnmarshalType is returned when the an unsupported type is
// encountered during unmarshaling.
type ErrUnsupportedUnmarshalType struct {
error
}
// NewErrUnsupportedUnmarshalType constructs a new unsupported unmarshal type
// error for the given type.
func NewErrUnsupportedUnmarshalType(v interface{}) error {
return ErrUnsupportedUnmarshalType{error: fmt.Errorf("unmarshal error: unsupported type %T", v)}
}