-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
47 lines (36 loc) · 1.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
package buffer
import (
"fmt"
"github.com/chronos-tachyon/enumhelper"
)
// Error is the type for the error constants returned by this package.
type Error byte
const (
// ErrEmpty is returned when reading from an empty Buffer.
ErrEmpty Error = iota
// ErrFull is returned when writing to a full Buffer.
ErrFull
// ErrBadDistance is returned when Window.LookupByte is called with a
// distance that isn't contained within the Window.
ErrBadDistance
)
var errorData = [...]enumhelper.EnumData{
{GoName: "ErrEmpty"},
{GoName: "ErrFull"},
{GoName: "ErrBadDistance"},
}
var errorText = [...]string{
"buffer is empty",
"buffer is full",
"given distance lies outside of sliding window",
}
// GoString returns the name of the Go constant.
func (err Error) GoString() string {
return enumhelper.DereferenceEnumData("Error", errorData[:], uint(err)).GoName
}
// Error returns the error message for this error.
func (err Error) Error() string {
return errorText[err]
}
var _ fmt.GoStringer = Error(0)
var _ error = Error(0)