1package tengo 2 3import ( 4 "errors" 5 "fmt" 6) 7 8var ( 9 // ErrStackOverflow is a stack overflow error. 10 ErrStackOverflow = errors.New("stack overflow") 11 12 // ErrObjectAllocLimit is an objects allocation limit error. 13 ErrObjectAllocLimit = errors.New("object allocation limit exceeded") 14 15 // ErrIndexOutOfBounds is an error where a given index is out of the 16 // bounds. 17 ErrIndexOutOfBounds = errors.New("index out of bounds") 18 19 // ErrInvalidIndexType represents an invalid index type. 20 ErrInvalidIndexType = errors.New("invalid index type") 21 22 // ErrInvalidIndexValueType represents an invalid index value type. 23 ErrInvalidIndexValueType = errors.New("invalid index value type") 24 25 // ErrInvalidIndexOnError represents an invalid index on error. 26 ErrInvalidIndexOnError = errors.New("invalid index on error") 27 28 // ErrInvalidOperator represents an error for invalid operator usage. 29 ErrInvalidOperator = errors.New("invalid operator") 30 31 // ErrWrongNumArguments represents a wrong number of arguments error. 32 ErrWrongNumArguments = errors.New("wrong number of arguments") 33 34 // ErrBytesLimit represents an error where the size of bytes value exceeds 35 // the limit. 36 ErrBytesLimit = errors.New("exceeding bytes size limit") 37 38 // ErrStringLimit represents an error where the size of string value 39 // exceeds the limit. 40 ErrStringLimit = errors.New("exceeding string size limit") 41 42 // ErrNotIndexable is an error where an Object is not indexable. 43 ErrNotIndexable = errors.New("not indexable") 44 45 // ErrNotIndexAssignable is an error where an Object is not index 46 // assignable. 47 ErrNotIndexAssignable = errors.New("not index-assignable") 48 49 // ErrNotImplemented is an error where an Object has not implemented a 50 // required method. 51 ErrNotImplemented = errors.New("not implemented") 52 53 // ErrInvalidRangeStep is an error where the step parameter is less than or equal to 0 when using builtin range function. 54 ErrInvalidRangeStep = errors.New("range step must be greater than 0") 55) 56 57// ErrInvalidArgumentType represents an invalid argument value type error. 58type ErrInvalidArgumentType struct { 59 Name string 60 Expected string 61 Found string 62} 63 64func (e ErrInvalidArgumentType) Error() string { 65 return fmt.Sprintf("invalid type for argument '%s': expected %s, found %s", 66 e.Name, e.Expected, e.Found) 67} 68