diff --git a/.changelog/unreleased/improvements/1356-impl-From-Infallible-for-ClientError.md b/.changelog/unreleased/improvements/1356-impl-From-Infallible-for-ClientError.md new file mode 100644 index 000000000..e453d3f20 --- /dev/null +++ b/.changelog/unreleased/improvements/1356-impl-From-Infallible-for-ClientError.md @@ -0,0 +1,2 @@ +- [ibc-core] Implement `From` for `ClientError` + ([#1356](https://github.com/cosmos/ibc-rs/issues/1356)). diff --git a/ibc-core/ics02-client/types/src/error.rs b/ibc-core/ics02-client/types/src/error.rs index bdd4b509f..49ced05dd 100644 --- a/ibc-core/ics02-client/types/src/error.rs +++ b/ibc-core/ics02-client/types/src/error.rs @@ -1,5 +1,7 @@ //! Defines the client error type +use core::convert::Infallible; + use displaydoc::Display; use ibc_core_commitment_types::error::CommitmentError; use ibc_core_host_types::error::{DecodingError, HostError, IdentifierError}; @@ -88,6 +90,12 @@ impl From for ClientError { } } +impl From for ClientError { + fn from(value: Infallible) -> Self { + match value {} + } +} + #[cfg(feature = "std")] impl std::error::Error for ClientError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { diff --git a/ibc-core/ics24-host/types/src/error.rs b/ibc-core/ics24-host/types/src/error.rs index 580fcc90b..3eb5b75e0 100644 --- a/ibc-core/ics24-host/types/src/error.rs +++ b/ibc-core/ics24-host/types/src/error.rs @@ -125,6 +125,12 @@ impl From for DecodingError { } } +impl From for DecodingError { + fn from(e: ProstError) -> Self { + Self::Prost(e) + } +} + impl From for DecodingError { fn from(e: Base64Error) -> Self { Self::Base64(e)