-
Notifications
You must be signed in to change notification settings - Fork 303
/
errors.go
67 lines (50 loc) · 2.24 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
package tengo
import (
"errors"
"fmt"
)
var (
// ErrStackOverflow is a stack overflow error.
ErrStackOverflow = errors.New("stack overflow")
// ErrObjectAllocLimit is an objects allocation limit error.
ErrObjectAllocLimit = errors.New("object allocation limit exceeded")
// ErrIndexOutOfBounds is an error where a given index is out of the
// bounds.
ErrIndexOutOfBounds = errors.New("index out of bounds")
// ErrInvalidIndexType represents an invalid index type.
ErrInvalidIndexType = errors.New("invalid index type")
// ErrInvalidIndexValueType represents an invalid index value type.
ErrInvalidIndexValueType = errors.New("invalid index value type")
// ErrInvalidIndexOnError represents an invalid index on error.
ErrInvalidIndexOnError = errors.New("invalid index on error")
// ErrInvalidOperator represents an error for invalid operator usage.
ErrInvalidOperator = errors.New("invalid operator")
// ErrWrongNumArguments represents a wrong number of arguments error.
ErrWrongNumArguments = errors.New("wrong number of arguments")
// ErrBytesLimit represents an error where the size of bytes value exceeds
// the limit.
ErrBytesLimit = errors.New("exceeding bytes size limit")
// ErrStringLimit represents an error where the size of string value
// exceeds the limit.
ErrStringLimit = errors.New("exceeding string size limit")
// ErrNotIndexable is an error where an Object is not indexable.
ErrNotIndexable = errors.New("not indexable")
// ErrNotIndexAssignable is an error where an Object is not index
// assignable.
ErrNotIndexAssignable = errors.New("not index-assignable")
// ErrNotImplemented is an error where an Object has not implemented a
// required method.
ErrNotImplemented = errors.New("not implemented")
// ErrInvalidRangeStep is an error where the step parameter is less than or equal to 0 when using builtin range function.
ErrInvalidRangeStep = errors.New("range step must be greater than 0")
)
// ErrInvalidArgumentType represents an invalid argument value type error.
type ErrInvalidArgumentType struct {
Name string
Expected string
Found string
}
func (e ErrInvalidArgumentType) Error() string {
return fmt.Sprintf("invalid type for argument '%s': expected %s, found %s",
e.Name, e.Expected, e.Found)
}