@@ -65,9 +65,20 @@ macro_rules! error_chain_processed {
65
65
pub state: $crate:: State ,
66
66
}
67
67
68
- impl_error!( $error_name
69
- $error_kind_name
70
- $( [ $link_error_path, $( #[ $meta_links] ) * ] ) * ) ;
68
+ impl $crate:: ChainedError for $error_name {
69
+ type ErrorKind = $error_kind_name;
70
+
71
+ fn new( kind: $error_kind_name, state: $crate:: State ) -> $error_name {
72
+ $error_name {
73
+ kind: kind,
74
+ state: state,
75
+ }
76
+ }
77
+
78
+ impl_extract_backtrace!( $error_name
79
+ $error_kind_name
80
+ $( [ $link_error_path, $( #[ $meta_links] ) * ] ) * ) ;
81
+ }
71
82
72
83
#[ allow( dead_code) ]
73
84
impl $error_name {
@@ -311,35 +322,24 @@ macro_rules! error_chain {
311
322
#[ macro_export]
312
323
#[ doc( hidden) ]
313
324
#[ cfg( feature = "backtrace" ) ]
314
- macro_rules! impl_error {
325
+ macro_rules! impl_extract_backtrace {
315
326
( $error_name: ident
316
327
$error_kind_name: ident
317
328
$( [ $link_error_path: path, $( #[ $meta_links: meta] ) * ] ) * ) => {
318
- impl $crate:: ChainedError for $error_name {
319
- type ErrorKind = $error_kind_name;
320
-
321
- fn new( kind: $error_kind_name, state: $crate:: State ) -> $error_name {
322
- $error_name {
323
- kind: kind,
324
- state: state,
325
- }
329
+ fn extract_backtrace( e: & ( :: std:: error:: Error + Send + ' static ) )
330
+ -> Option <Option <:: std:: sync:: Arc <$crate:: Backtrace >>> {
331
+ if let Some ( e) = e. downcast_ref:: <$error_name>( ) {
332
+ return Some ( e. state. backtrace. clone( ) ) ;
326
333
}
327
-
328
- fn extract_backtrace( e: & ( :: std:: error:: Error + Send + ' static ) )
329
- -> Option <Option <:: std:: sync:: Arc <$crate:: Backtrace >>> {
330
- if let Some ( e) = e. downcast_ref:: <$error_name>( ) {
331
- return Some ( e. state. backtrace. clone( ) ) ;
332
- }
333
- $(
334
- $( #[ $meta_links] ) *
335
- {
336
- if let Some ( e) = e. downcast_ref:: <$link_error_path>( ) {
337
- return Some ( e. state. backtrace. clone( ) ) ;
338
- }
334
+ $(
335
+ $( #[ $meta_links] ) *
336
+ {
337
+ if let Some ( e) = e. downcast_ref:: <$link_error_path>( ) {
338
+ return Some ( e. state. backtrace. clone( ) ) ;
339
339
}
340
- ) *
341
- None
342
- }
340
+ }
341
+ ) *
342
+ None
343
343
}
344
344
}
345
345
}
@@ -352,19 +352,8 @@ macro_rules! impl_error {
352
352
#[ macro_export]
353
353
#[ doc( hidden) ]
354
354
#[ cfg( not( feature = "backtrace" ) ) ]
355
- macro_rules! impl_error {
355
+ macro_rules! impl_extract_backtrace {
356
356
( $error_name: ident
357
357
$error_kind_name: ident
358
- $( [ $link_error_path: path, $( #[ $meta_links: meta] ) * ] ) * ) => {
359
- impl $crate:: ChainedError for $error_name {
360
- type ErrorKind = $error_kind_name;
361
-
362
- fn new( kind: $error_kind_name, state: $crate:: State ) -> $error_name {
363
- $error_name {
364
- kind: kind,
365
- state: state,
366
- }
367
- }
368
- }
369
- }
358
+ $( [ $link_error_path: path, $( #[ $meta_links: meta] ) * ] ) * ) => { }
370
359
}
0 commit comments