Lines Matching full:error
4 use thiserror::Error;
12 #[derive(Error, Debug)] in test_braced()
13 #[error("braced error: {msg}")] in test_braced()
14 struct Error { in test_braced() struct
19 assert("braced error: T", Error { msg }); in test_braced()
24 #[derive(Error, Debug)] in test_braced_unused()
25 #[error("braced error")] in test_braced_unused()
26 struct Error { in test_braced_unused() struct
30 assert("braced error", Error { extra: 0 }); in test_braced_unused()
35 #[derive(Error, Debug)] in test_tuple()
36 #[error("tuple error: {0}")] in test_tuple()
37 struct Error(usize); in test_tuple() struct
39 assert("tuple error: 0", Error(0)); in test_tuple()
44 #[derive(Error, Debug)] in test_unit()
45 #[error("unit error")] in test_unit()
46 struct Error; in test_unit() struct
48 assert("unit error", Error); in test_unit()
53 #[derive(Error, Debug)] in test_enum()
54 enum Error { in test_enum() enum
55 #[error("braced error: {id}")] in test_enum()
57 #[error("tuple error: {0}")] in test_enum()
59 #[error("unit error")] in test_enum()
63 assert("braced error: 0", Error::Braced { id: 0 }); in test_enum()
64 assert("tuple error: 0", Error::Tuple(0)); in test_enum()
65 assert("unit error", Error::Unit); in test_enum()
70 #[derive(Error, Debug)] in test_constants()
71 #[error("{MSG}: {id:?} (code {CODE:?})")] in test_constants()
72 struct Error { in test_constants() struct
79 assert("failed to do: \"\" (code 9)", Error { id: "" }); in test_constants()
84 #[derive(Error, Debug)] in test_inherit()
85 #[error("{0}")] in test_inherit()
86 enum Error { in test_inherit() enum
88 #[error("other error")] in test_inherit()
92 assert("some error", Error::Some("some error")); in test_inherit()
93 assert("other error", Error::Other("...")); in test_inherit()
98 #[derive(Error, Debug)] in test_brace_escape()
99 #[error("fn main() {{}}")] in test_brace_escape()
100 struct Error; in test_brace_escape() struct
102 assert("fn main() {}", Error); in test_brace_escape()
107 #[derive(Error, Debug)] in test_expr()
108 #[error("1 + 1 = {}", 1 + 1)] in test_expr()
109 struct Error; in test_expr() struct
110 assert("1 + 1 = 2", Error); in test_expr()
115 #[derive(Error, Debug)] in test_nested()
116 #[error("!bool = {}", not(.0))] in test_nested()
117 struct Error(bool); in test_nested() struct
124 assert("!bool = false", Error(true)); in test_nested()
129 #[derive(Error, Debug)] in test_match()
130 #[error("{}: {0}", match .1 { in test_match()
131 Some(n) => format!("error occurred with {}", n), in test_match()
132 None => "there was an empty error".to_owned(), in test_match()
134 struct Error(String, Option<usize>); in test_match() struct
137 "error occurred with 1: ...", in test_match()
138 Error("...".to_owned(), Some(1)), in test_match()
141 "there was an empty error: ...", in test_match()
142 Error("...".to_owned(), None), in test_match()
149 #[derive(Error, Debug)] in test_nested_display()
150 #[error("{}", { in test_nested_display()
155 Some(n) => write!(formatter, "error occurred with {}", n), in test_nested_display()
156 None => write!(formatter, "there was an empty error"), in test_nested_display()
163 struct Error(String, Option<usize>); in test_nested_display() struct
166 "error occurred with 1: ...", in test_nested_display()
167 Error("...".to_owned(), Some(1)), in test_nested_display()
170 "there was an empty error: ...", in test_nested_display()
171 Error("...".to_owned(), None), in test_nested_display()
178 #[derive(Error, Debug)] in test_void()
179 #[error("...")] in test_void()
180 pub enum Error {} in test_void() enum
182 let _: Error; in test_void()
187 #[derive(Error, Debug)] in test_mixed()
188 #[error("a={a} :: b={} :: c={c} :: d={d}", 1, c = 2, d = 3)] in test_mixed()
189 struct Error { in test_mixed() struct
194 assert("a=0 :: b=1 :: c=2 :: d=3", Error { a: 0, d: 0 }); in test_mixed()
199 #[derive(Error, Debug)] in test_ints()
200 enum Error { in test_ints() enum
201 #[error("error {0}")] in test_ints()
203 #[error("error {0}", '?')] in test_ints()
207 assert("error 9", Error::Tuple(9, 0)); in test_ints()
208 assert("error ?", Error::Struct { v: 0 }); in test_ints()
213 #[derive(Error, Debug)] in test_trailing_comma()
214 #[error( in test_trailing_comma()
215 "error {0}", in test_trailing_comma()
218 struct Error(char); in test_trailing_comma() struct
220 assert("error ?", Error('?')); in test_trailing_comma()
230 #[derive(Error, Debug)] in test_field()
231 #[error("{}", .0.data)] in test_field()
232 struct Error(Inner); in test_field() struct
234 assert("0", Error(Inner { data: 0 })); in test_field()
243 #[derive(Debug, Error)] in test_macro_rules()
245 #[error("{0:?}")] in test_macro_rules()
249 #[derive(Debug, Error)] in test_macro_rules()
250 #[error("{0:?}")] in test_macro_rules()
265 #[derive(Error, Debug)] in test_raw()
266 #[error("braced raw error: {r#fn}")] in test_raw()
267 struct Error { in test_raw() struct
271 assert("braced raw error: T", Error { r#fn: "T" }); in test_raw()
276 #[derive(Error, Debug)] in test_raw_enum()
277 enum Error { in test_raw_enum() enum
278 #[error("braced raw error: {r#fn}")] in test_raw_enum()
282 assert("braced raw error: T", Error::Braced { r#fn: "T" }); in test_raw_enum()
287 #[derive(Error, Debug)] in test_raw_conflict()
288 enum Error { in test_raw_conflict() enum
289 #[error("braced raw error: {r#func}, {func}", func = "U")] in test_raw_conflict()
293 assert("braced raw error: T, U", Error::Braced { r#func: "T" }); in test_raw_conflict()
298 #[derive(Error, Debug)] in test_keyword()
299 #[error("error: {type}", type = 1)] in test_keyword()
300 struct Error; in test_keyword() struct
302 assert("error: 1", Error); in test_keyword()