@@ -59,7 +59,9 @@ macro_rules! error_chain_processed {
5959 pub state: $crate:: State ,
6060 }
6161
62- impl_error!( $error_name $error_kind_name $( $link_error_path) * ) ;
62+ impl_error!( $error_name
63+ $error_kind_name
64+ $( [ $link_error_path, $( #[ $meta_links] ) * ] ) * ) ;
6365
6466 impl $error_name {
6567 /// Constructs an error from a kind.
@@ -300,7 +302,7 @@ macro_rules! error_chain {
300302macro_rules! impl_error {
301303 ( $error_name: ident
302304 $error_kind_name: ident
303- $( $link_error_path: path) * ) => {
305+ $( [ $link_error_path: path, $ ( # [ $meta_links : meta ] ) * ] ) * ) => {
304306 impl $error_name {
305307 /// Returns the backtrace associated with this error.
306308 pub fn backtrace( & self ) -> Option <& $crate:: Backtrace > {
@@ -321,16 +323,17 @@ macro_rules! impl_error {
321323 fn extract_backtrace( e: & ( :: std:: error:: Error + Send + ' static ) )
322324 -> Option <Option <:: std:: sync:: Arc <$crate:: Backtrace >>> {
323325 if let Some ( e) = e. downcast_ref:: <$error_name>( ) {
324- Some ( e. state. backtrace. clone( ) )
326+ return Some ( e. state. backtrace. clone( ) ) ;
325327 }
326328 $(
327- else if let Some ( e) = e. downcast_ref:: <$link_error_path>( ) {
328- Some ( e. state. backtrace. clone( ) )
329+ $( #[ $meta_links] ) *
330+ {
331+ if let Some ( e) = e. downcast_ref:: <$link_error_path>( ) {
332+ return Some ( e. state. backtrace. clone( ) ) ;
333+ }
329334 }
330335 ) *
331- else {
332- None
333- }
336+ None
334337 }
335338 }
336339 }
@@ -347,7 +350,7 @@ macro_rules! impl_error {
347350macro_rules! impl_error {
348351 ( $error_name: ident
349352 $error_kind_name: ident
350- $( $link_error_path: path) * ) => {
353+ $( [ $link_error_path: path, $ ( # [ $meta_links : meta ] ) * ] ) * ) => {
351354 impl $crate:: ChainedError for $error_name {
352355 type ErrorKind = $error_kind_name;
353356
0 commit comments