-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
222 lines (205 loc) · 12.8 KB
/
errors.go
File metadata and controls
222 lines (205 loc) · 12.8 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package template
import "errors"
// ErrTemplateNotFound indicates a loader could not locate the named template.
// ErrInvalidTemplateName indicates the template name failed fs.ValidPath validation
// (contains "..", is absolute, contains NUL, backslash, or similar).
// ErrIncludeDepthExceeded indicates include nesting exceeded the hard limit.
// ErrExtendsDepthExceeded indicates the extends chain exceeded the hard limit.
// ErrCircularExtends indicates a cycle was detected in the extends chain.
// ErrExtendsNotFirst indicates an extends tag appeared after other content.
// ErrExtendsPathNotLiteral indicates an extends path was an expression, not a string literal.
// ErrBlockRedefined indicates the same block name appeared twice in one template.
// ErrUnclosedRaw indicates a raw block was not terminated with endraw.
// ErrIncludePathNotString indicates a dynamic include path evaluated to a non-string value.
var (
ErrTemplateNotFound = errors.New("template not found")
ErrInvalidTemplateName = errors.New("invalid template name")
ErrIncludeDepthExceeded = errors.New("include depth exceeded")
ErrExtendsDepthExceeded = errors.New("extends depth exceeded")
ErrCircularExtends = errors.New("circular extends detected")
ErrExtendsNotFirst = errors.New("extends must be the first tag")
ErrExtendsPathNotLiteral = errors.New("extends path must be a string literal")
ErrBlockRedefined = errors.New("block redefined in same template")
ErrUnclosedRaw = errors.New("unclosed raw block")
ErrIncludePathNotString = errors.New("include path did not evaluate to string")
)
// ErrContextKeyNotFound indicates a key was not found in the render data.
// ErrContextInvalidKeyType indicates an invalid key type during context navigation.
// ErrContextIndexOutOfRange indicates an index out of range during context navigation.
var (
ErrContextKeyNotFound = errors.New("key not found in context")
ErrContextInvalidKeyType = errors.New("invalid key type for navigation")
ErrContextIndexOutOfRange = errors.New("index out of range in context")
)
// ErrFilterNotFound indicates a referenced filter does not exist.
// ErrFilterExecutionFailed indicates a filter failed during execution.
// ErrFilterInputInvalid indicates the filter received invalid input.
// ErrFilterArgsInvalid indicates the filter received invalid arguments.
// ErrFilterInputEmpty indicates the filter received empty input.
// ErrFilterInputNotSlice indicates the filter expected a slice input.
// ErrFilterInputNotNumeric indicates the filter expected numeric input.
// ErrFilterInputInvalidTimeFormat indicates the filter received an invalid time format.
// ErrFilterInputUnsupportedType indicates the filter received an unsupported input type.
// ErrInsufficientArgs indicates insufficient arguments were provided to a filter.
// ErrInvalidFilterName indicates an invalid filter name was used.
// ErrUnknownFilterArgumentType indicates an unknown argument type was passed to a filter.
// ErrExpectedFilterName indicates a filter name was expected after the pipe operator.
var (
ErrFilterNotFound = errors.New("filter not found")
ErrFilterExecutionFailed = errors.New("filter execution failed")
ErrFilterInputInvalid = errors.New("filter input is invalid")
ErrFilterArgsInvalid = errors.New("filter arguments are invalid")
ErrFilterInputEmpty = errors.New("filter input is empty")
ErrFilterInputNotSlice = errors.New("filter input is not a slice")
ErrFilterInputNotNumeric = errors.New("filter input is not numeric")
ErrFilterInputInvalidTimeFormat = errors.New("filter input has an invalid time format")
ErrFilterInputUnsupportedType = errors.New("filter input is of an unsupported type")
ErrInsufficientArgs = errors.New("insufficient arguments provided")
ErrInvalidFilterName = errors.New("invalid filter name")
ErrUnknownFilterArgumentType = errors.New("unknown argument type")
ErrExpectedFilterName = errors.New("expected filter name after '|'")
)
// ErrUnexpectedCharacter indicates the lexer encountered an unexpected character.
// ErrUnterminatedString indicates a string literal was not properly closed.
var (
ErrUnexpectedCharacter = errors.New("unexpected character")
ErrUnterminatedString = errors.New("unterminated string literal")
)
// ErrInvalidNumber indicates the parser encountered an invalid numeric literal.
// ErrExpectedRParen indicates a closing parenthesis was expected but not found.
// ErrUnexpectedToken indicates the parser encountered an unexpected token.
// ErrUnknownNodeType indicates an unknown AST node type was encountered.
// ErrIntegerOverflow indicates an unsigned integer value exceeds the maximum int64 value.
var (
ErrInvalidNumber = errors.New("invalid number")
ErrExpectedRParen = errors.New("expected ')'")
ErrUnexpectedToken = errors.New("unexpected token")
ErrUnknownNodeType = errors.New("unknown node type")
ErrIntegerOverflow = errors.New("unsigned integer value exceeds maximum int64 value")
)
// ErrUnsupportedType indicates an unsupported type was encountered.
// ErrUnsupportedOperator indicates an unsupported operator was used.
// ErrUnsupportedUnaryOp indicates an unsupported unary operator was used.
var (
ErrUnsupportedType = errors.New("unsupported type")
ErrUnsupportedOperator = errors.New("unsupported operator")
ErrUnsupportedUnaryOp = errors.New("unsupported unary operator")
)
// ErrUndefinedVariable indicates a referenced variable is not defined.
// ErrUndefinedProperty indicates a referenced property is not defined.
// ErrNonStructProperty indicates a property access was attempted on a non-struct value.
// ErrCannotAccessProperty indicates a property cannot be accessed.
// ErrNonObjectProperty indicates a property access was attempted on a non-object value.
// ErrInvalidVariableAccess indicates an invalid variable access pattern.
var (
ErrUndefinedVariable = errors.New("undefined variable")
ErrUndefinedProperty = errors.New("undefined property")
ErrNonStructProperty = errors.New("cannot access property of non-struct value")
ErrCannotAccessProperty = errors.New("cannot access property")
ErrNonObjectProperty = errors.New("cannot access property of non-object")
ErrInvalidVariableAccess = errors.New("invalid variable access")
)
// ErrCannotAddTypes indicates addition is not supported for the given types.
// ErrCannotSubtractTypes indicates subtraction is not supported for the given types.
// ErrCannotMultiplyTypes indicates multiplication is not supported for the given types.
// ErrCannotDivideTypes indicates division is not supported for the given types.
// ErrCannotModuloTypes indicates modulo is not supported for the given types.
// ErrDivisionByZero indicates a division by zero was attempted.
// ErrModuloByZero indicates a modulo by zero was attempted.
// ErrCannotConvertToBool indicates a value cannot be converted to boolean.
// ErrCannotNegate indicates a value cannot be negated.
// ErrCannotApplyUnaryPlus indicates unary plus cannot be applied to the value.
// ErrCannotCompareTypes indicates comparison is not supported for the given types.
var (
ErrCannotAddTypes = errors.New("cannot add values of these types")
ErrCannotSubtractTypes = errors.New("cannot subtract values of these types")
ErrCannotMultiplyTypes = errors.New("cannot multiply values of these types")
ErrCannotDivideTypes = errors.New("cannot divide values of these types")
ErrCannotModuloTypes = errors.New("cannot modulo values of these types")
ErrDivisionByZero = errors.New("division by zero")
ErrModuloByZero = errors.New("modulo by zero")
ErrCannotConvertToBool = errors.New("cannot convert type to boolean")
ErrCannotNegate = errors.New("cannot negate value")
ErrCannotApplyUnaryPlus = errors.New("cannot apply unary plus")
ErrCannotCompareTypes = errors.New("cannot compare values of these types")
)
// ErrInvalidIndexType indicates an invalid index type was used.
// ErrInvalidArrayIndex indicates an invalid array index was used.
// ErrIndexOutOfRange indicates an index is out of range.
// ErrCannotIndexNil indicates an indexing operation was attempted on nil.
// ErrTypeNotIndexable indicates the type does not support indexing.
// ErrCannotGetKeyFromNil indicates a key lookup was attempted on nil.
// ErrTypeNotMap indicates the type is not a map.
// ErrCannotGetFieldFromNil indicates a field access was attempted on nil.
// ErrStructHasNoField indicates the struct does not have the requested field.
// ErrTypeHasNoField indicates the type does not have the requested field.
// ErrUnsupportedArrayType indicates an unsupported array type was encountered.
var (
ErrInvalidIndexType = errors.New("invalid index type")
ErrInvalidArrayIndex = errors.New("invalid array index")
ErrIndexOutOfRange = errors.New("index out of range")
ErrCannotIndexNil = errors.New("cannot index nil")
ErrTypeNotIndexable = errors.New("type is not indexable")
ErrCannotGetKeyFromNil = errors.New("cannot get key from nil")
ErrTypeNotMap = errors.New("type is not a map")
ErrCannotGetFieldFromNil = errors.New("cannot get field from nil")
ErrStructHasNoField = errors.New("struct has no field")
ErrTypeHasNoField = errors.New("type has no field")
ErrUnsupportedArrayType = errors.New("unsupported array type")
)
// ErrUnsupportedCollectionType indicates the collection type is not supported in a for loop.
// ErrTypeNotIterable indicates the type does not support iteration.
// ErrTypeHasNoLength indicates the type does not support the length operation.
var (
ErrUnsupportedCollectionType = errors.New("unsupported collection type for for loop")
ErrTypeNotIterable = errors.New("type is not iterable")
ErrTypeHasNoLength = errors.New("type has no length")
)
// ErrCannotConvertNilToInt indicates nil cannot be converted to int.
// ErrCannotConvertToInt indicates the value cannot be converted to int.
// ErrCannotConvertNilToFloat indicates nil cannot be converted to float.
// ErrCannotConvertToFloat indicates the value cannot be converted to float.
var (
ErrCannotConvertNilToInt = errors.New("cannot convert nil to int")
ErrCannotConvertToInt = errors.New("cannot convert value to int")
ErrCannotConvertNilToFloat = errors.New("cannot convert nil to float")
ErrCannotConvertToFloat = errors.New("cannot convert value to float")
ErrExpectedSliceOrArray = errors.New("expected slice or array")
)
// ErrBreakOutsideLoop indicates a break statement was used outside of a loop.
// ErrContinueOutsideLoop indicates a continue statement was used outside of a loop.
var (
ErrBreakOutsideLoop = errors.New("break statement outside of loop")
ErrContinueOutsideLoop = errors.New("continue statement outside of loop")
)
// ErrTagAlreadyRegistered indicates a tag with the same name is already registered.
//
// ErrMultipleElseStatements indicates multiple else clauses were found in an if block.
// ErrUnexpectedTokensAfterCondition indicates unexpected tokens after a condition expression.
// ErrElseNoArgs indicates the else tag received unexpected arguments.
// ErrEndifNoArgs indicates the endif tag received unexpected arguments.
// ErrElifAfterElse indicates an elif clause appeared after an else clause.
//
// ErrExpectedVariable indicates a variable name was expected but not found.
// ErrExpectedSecondVariable indicates a second variable name was expected after a comma.
// ErrExpectedInKeyword indicates the "in" keyword was expected but not found.
// ErrUnexpectedTokensAfterCollection indicates unexpected tokens after a collection expression.
// ErrEndforNoArgs indicates the endfor tag received unexpected arguments.
//
// ErrBreakNoArgs indicates the break tag received unexpected arguments.
// ErrContinueNoArgs indicates the continue tag received unexpected arguments.
var (
ErrTagAlreadyRegistered = errors.New("tag already registered")
ErrMultipleElseStatements = errors.New("multiple 'else' statements found in if block, use 'elif' for additional conditions")
ErrUnexpectedTokensAfterCondition = errors.New("unexpected tokens after condition")
ErrElseNoArgs = errors.New("else does not take arguments")
ErrEndifNoArgs = errors.New("endif does not take arguments")
ErrElifAfterElse = errors.New("elif cannot appear after else")
ErrExpectedVariable = errors.New("expected variable name")
ErrExpectedSecondVariable = errors.New("expected second variable name after comma")
ErrExpectedInKeyword = errors.New("expected 'in' keyword")
ErrUnexpectedTokensAfterCollection = errors.New("unexpected tokens after collection")
ErrEndforNoArgs = errors.New("endfor does not take arguments")
ErrBreakNoArgs = errors.New("break does not take arguments")
ErrContinueNoArgs = errors.New("continue does not take arguments")
)