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
use std::collections::{LinkedList};
use serde_json::value::Value;
pub type TeraResult<T> = Result<T, TeraError>;
quick_error! {
#[derive(PartialEq, Debug, Clone)]
pub enum TeraError {
MismatchingEndTag(line_no: usize, col_no: usize, expected: String, found: String) {
display("Was expecting block with name `{}` to be closed, but `{}` is closing at line {:?}, column {:?}",
expected, found, line_no, col_no)
description("unexpected end tag name")
}
InvalidSyntax(line_no: usize, col_no: usize) {
display("invalid Tera syntax at line {:?}, column {:?}", line_no, col_no)
description("invalid Tera syntax")
}
DeprecatedSyntax(line_no: usize, col_no: usize, message: String) {
display("deprecated syntax at line {:?}, column {:?}: {}", line_no, col_no, message)
description("deprecated syntax")
}
InvalidValue(name: String) {
display("Expected the value to be an Object while rendering `{}`.", name)
description("invalid value")
}
TemplateNotFound(name: String) {
display("Template `{}` was not found", name)
description("template not found")
}
FilterNotFound(name: String) {
display("Filter `{}` was not found.", name)
description("filter not found")
}
MacroNotFound(name: String, namespace: String) {
display("Macro `{}` was not found in the namespace `{}`.", name, namespace)
description("macro not found")
}
NotANumber(name: String) {
display("Field `{}` was used in a math operation but is not a number", name)
description("field is not a number")
}
NotAnArray(name: String) {
display("Field `{}` is not an array but was used as iterator in forloop", name)
description("field is not an array")
}
FieldNotFound(name: String) {
display("Field `{}` was not found in the context.", name)
description("field not found")
}
Internal(message: String) {
display("Tera encountered an internal error: {}", message)
description("tera internal error")
}
FilterIncorrectArgType(filter_name: String, arg_name: String, arg_value: Value, expected_type: String) {
display("Filter `{}` received an incorrect type for arg `{}`: got {:?} but expected a {}", filter_name, arg_name, arg_value, expected_type)
description("incorrect filter arg type")
}
FilterMissingArg(filter_name: String, arg_name: String) {
display("Filter `{}` expected an arg called `{}`", filter_name, arg_name)
description("missing arg in filter call")
}
TesterNotFound(name: String) {
display("Tester `{}` was not found in the context.", name)
description("tester not found")
}
TestError(tester_name: String, message: String) {
display("Tester `{}` encountered an error while running: {}", tester_name, message)
description("tester runtime error")
}
MacroCallWrongArgs(macro_name: String, expected_args: LinkedList<String>, args: Vec<String>) {
display("Macro `{}` got `{:?}` for args but was expecting `{:?}` (order does not matter)", macro_name, expected_args, args)
description("macro wrong args")
}
}
}