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
use std::fmt;
use std::io;
use std::error::Error;
use Pos;
quick_error! {
#[derive(Debug)]
pub enum DataError {
AttrUnsupported(typename: &'static str) {
description("object doesn't support getting attribute `a.b`")
display("object {} doesn't support getting attribute", typename)
}
AttrNotFound {
description("object doesn't have such attibute")
}
IndexUnsupported(typename: &'static str) {
description("object doesn't support subscription `a[b]`")
display("object {} doesn't support subscription", typename)
}
StrKeyUnsupported(typename: &'static str) {
description("can't be stringified for subsciption `a[b]`")
display("object {} can't be stringified to be used as key", typename)
}
IntKeyUnsupported(typename: &'static str) {
description("can't used as integer key for subscription")
display("object {} can't be a key for subscription", typename)
}
IndexNotFound {
description("object doesn't have value at specified index")
}
OutputUnsupported(typename: &'static str) {
description("can't print object of this type")
display("can't print object of type {}", typename)
}
OutputError(typename: &'static str) {
description("error when formatting value")
display("error when formatting value of type {}", typename)
}
UnknownValidator(name: String) {
description("unknown validator")
display("validator {:?} is not defined", name)
}
RegexValidationError(data: String, regex: String) {
description("validation error")
display("output {:?} should match regex {:?}", data, regex)
}
BoolUnsupported(typename: &'static str) {
description("can't treat object of this type as bool")
display("can't treat object of type {} as bool", typename)
}
NumberUnsupported(typename: &'static str) {
description("can't treat object of this type as number")
display("can't treat object of type {} as number", typename)
}
ComparisonUnsupported(typename: &'static str) {
description("can't compare objects of this type")
display("can't compare objects of type {}", typename)
}
IterationUnsupported(typename: &'static str) {
description("can't iterate over the object")
display("can't iterate over the object of type {}", typename)
}
PairIterationUnsupported(typename: &'static str) {
description("can't iterate over the object by pairs")
display("can't iterate over the object by pairs of type {}",
typename)
}
VariableNotFound(name: String) {
description("variable or attribute not found")
display("variable or attribute {:?} not found", name)
}
Custom(err: Box<Error>) {
description(err.description())
display("{}", err)
cause(&**err)
}
#[doc(hidden)]
__Nonexhaustive
}
}
quick_error! {
#[derive(Debug)]
pub enum RenderError {
Io(err: io::Error) {
display("I/O error: {}", err)
description("I/O error")
from()
}
Fmt(err: fmt::Error) {
description("error formatting value")
from()
}
Data(errs: Vec<(Pos, DataError)>) {
display("data error: {}", errs.iter()
.map(|&(p, ref e)| format!("{}: {}", p, e))
.collect::<Vec<_>>().join("\n "))
description("data error")
}
}
}