-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.go
More file actions
90 lines (72 loc) · 2.67 KB
/
errors.go
File metadata and controls
90 lines (72 loc) · 2.67 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package minecraft
import (
"errors"
"strconv"
"vimagination.zapto.org/minecraft/nbt"
)
var (
// ErrOOB is an error returned when sanity checking section data.
ErrOOB = errors.New("received out-of-bounds error")
// ErrNoLock is an error returns by path types to indicate that the lock on the
// minecraft level has been locked and needs reinstating to continue.
ErrNoLock = errors.New("lost lock on files")
)
// MissingTagError is an error type returned when an expected tag is not found.
type MissingTagError struct {
TagName string
}
func (m MissingTagError) Error() string {
return "minecraft: missing " + strconv.Quote(m.TagName) + " tag"
}
// WrongTypeError is an error returned when an nbt tag has an unexpected type.
type WrongTypeError struct {
TagName string
Expecting, Got nbt.TagID
}
func (w WrongTypeError) Error() string {
return "minecraft: tag " + strconv.Quote(w.TagName) + " is of incorrect type, expecting " + strconv.Quote(w.Expecting.String()) + ", got " + strconv.Quote(w.Got.String())
}
// UnexpectedValue is an error returned from chunk loading during sanity
// checking.
type UnexpectedValue struct {
TagName, Expecting, Got string
}
func (u UnexpectedValue) Error() string {
return "minecraft: tag " + strconv.Quote(u.TagName) + " was expecting " + strconv.Quote(u.Expecting) + ", but got " + strconv.Quote(u.Got)
}
// UnknownCompression is an error returned by path types when it encounters a
// compression scheme it is not prepared to handle or an unknown compression
// scheme.
type UnknownCompression struct {
Code byte
}
func (u UnknownCompression) Error() string {
return "unknown compression code: " + strconv.FormatUint(uint64(u.Code), 10)
}
// ConflictError is an error return by SetChunk when trying to save a single
// chunk multiple times during the same save operation.
type ConflictError struct {
X, Z int32
}
func (c ConflictError) Error() string {
return "already setting chunk " + strconv.FormatInt(int64(c.X), 10) + "," + strconv.FormatInt(int64(c.Z), 10) + ", recall SetChunk to set again"
}
// FilePathSetError is an error returned from SetChunk when some error is
// returned either from converting the nbt or saving it.
type FilePathSetError struct {
X, Z int32
Err error
}
func (f FilePathSetError) Error() string {
return "chunk " + strconv.FormatInt(int64(f.X), 10) + "," + strconv.FormatInt(int64(f.Z), 10) + " had the following error: " + f.Err.Error()
}
// MultiError is an error type that contains multiple errors.
type MultiError struct {
Errors []error
}
func (m MultiError) Error() string {
if len(m.Errors) == 1 {
return m.Errors[0].Error()
}
return "received " + strconv.FormatInt(int64(len(m.Errors)), 10) + " errors"
}