|
1 | 1 | #[doc(hidden)]
|
2 | 2 | #[macro_export]
|
3 | 3 | #[cfg(not(has_error_source))]
|
4 |
| -macro_rules! impl_error_chain_source { |
| 4 | +macro_rules! impl_error_chain_cause_or_source { |
5 | 5 | (
|
6 |
| - types { |
| 6 | + types { |
7 | 7 | $error_kind_name:ident
|
8 |
| - } |
9 |
| - foreign_links { |
10 |
| - $( $foreign_link_variant:ident ( $foreign_link_error_path:path ) |
11 |
| - $( #[$meta_foreign_links:meta] )*; )* |
12 |
| - }) => { |
13 |
| - |
14 |
| - #[allow(unknown_lints, renamed_and_removed_lints, unused_doc_comment, unused_doc_comments)] |
15 |
| - fn cause(&self) -> Option<&::std::error::Error> { |
16 |
| - match self.1.next_error { |
17 |
| - Some(ref c) => Some(&**c), |
18 |
| - None => { |
19 |
| - match self.0 { |
20 |
| - $( |
21 |
| - $(#[$meta_foreign_links])* |
22 |
| - $error_kind_name::$foreign_link_variant(ref foreign_err) => { |
23 |
| - foreign_err.cause() |
24 |
| - } |
25 |
| - ) * |
26 |
| - _ => None |
| 8 | + } |
| 9 | + |
| 10 | + foreign_links { |
| 11 | + $( $foreign_link_variant:ident ( $foreign_link_error_path:path ) |
| 12 | + $( #[$meta_foreign_links:meta] )*; )* |
| 13 | + } |
| 14 | + ) => { |
| 15 | + #[allow(unknown_lints, renamed_and_removed_lints, unused_doc_comment, unused_doc_comments)] |
| 16 | + fn cause(&self) -> Option<&::std::error::Error> { |
| 17 | + match self.1.next_error { |
| 18 | + Some(ref c) => Some(&**c), |
| 19 | + None => { |
| 20 | + match self.0 { |
| 21 | + $( |
| 22 | + $(#[$meta_foreign_links])* |
| 23 | + $error_kind_name::$foreign_link_variant(ref foreign_err) => { |
| 24 | + foreign_err.cause() |
| 25 | + } |
| 26 | + ) * |
| 27 | + _ => None |
| 28 | + } |
27 | 29 | }
|
28 | 30 | }
|
29 | 31 | }
|
30 |
| - } |
31 | 32 | };
|
32 | 33 | }
|
33 | 34 |
|
34 | 35 | #[cfg(has_error_source)]
|
35 | 36 | #[doc(hidden)]
|
36 | 37 | #[macro_export]
|
37 |
| -macro_rules! impl_error_chain_source { |
| 38 | +macro_rules! impl_error_chain_cause_or_source { |
38 | 39 | (
|
39 |
| - types { |
40 |
| - $error_kind_name:ident |
41 |
| - } |
42 |
| - foreign_links { |
43 |
| - $( $foreign_link_variant:ident ( $foreign_link_error_path:path ) |
44 |
| - $( #[$meta_foreign_links:meta] )*; )* |
45 |
| - }) => { |
| 40 | + types { |
| 41 | + $error_kind_name:ident |
| 42 | + } |
| 43 | + |
| 44 | + foreign_links { |
| 45 | + $( $foreign_link_variant:ident ( $foreign_link_error_path:path ) |
| 46 | + $( #[$meta_foreign_links:meta] )*; )* |
| 47 | + } |
| 48 | + ) => { |
46 | 49 |
|
47 | 50 | #[allow(unknown_lints, renamed_and_removed_lints, unused_doc_comment, unused_doc_comments)]
|
48 | 51 | fn source(&self) -> Option<&(std::error::Error + 'static)> {
|
@@ -245,7 +248,7 @@ macro_rules! impl_error_chain_processed {
|
245 | 248 | self.description()
|
246 | 249 | }
|
247 | 250 |
|
248 |
| - $crate::impl_error_chain_source!{ |
| 251 | + $crate::impl_error_chain_cause_or_source!{ |
249 | 252 | types {
|
250 | 253 | $error_kind_name
|
251 | 254 | }
|
|
0 commit comments