From ccfd4987a59410ea3c926c17c213736fbd5bae17 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Thu, 24 Feb 2022 18:44:44 +1100 Subject: [PATCH] Don't print inner error when returning as source According to https://github.com/rust-lang/project-error-handling/issues/44#issuecomment-858151860, we should not be printing the inner error AND returning it as source. Libraries like `anyhow` will traverse the chain of `source` errors and build up a composed error message. Printing it and returning the same error from `source` results in duplicate error messages in that case. --- core/src/transport.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/transport.rs b/core/src/transport.rs index 664d55b1d60..e13aecce96c 100644 --- a/core/src/transport.rs +++ b/core/src/transport.rs @@ -393,7 +393,7 @@ where TransportError::MultiaddrNotSupported(addr) => { write!(f, "Multiaddr is not supported: {}", addr) } - TransportError::Other(err) => write!(f, "{}", err), + TransportError::Other(_) => Ok(()), } } }