Skip to content

Commit

Permalink
Add derive_more::From on NftTransferError
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchen1991 committed Aug 29, 2024
1 parent c656b5f commit 234ebee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
3 changes: 2 additions & 1 deletion ibc-apps/ics20-transfer/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
use core::convert::Infallible;

use displaydoc::Display;
use uint::FromDecStrErr;

use ibc_core::channel::types::acknowledgement::StatusValue;
use ibc_core::channel::types::channel::Order;
use ibc_core::handler::types::error::ContextError;
use ibc_core::host::types::error::{DecodingError, IdentifierError};
use ibc_core::host::types::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;
use uint::FromDecStrErr;

#[derive(Display, Debug)]
pub enum TokenTransferError {
Expand Down
21 changes: 2 additions & 19 deletions ibc-apps/ics721-nft-transfer/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ use core::convert::Infallible;

use displaydoc::Display;
use http::uri::InvalidUri;

use ibc_core::channel::types::acknowledgement::StatusValue;
use ibc_core::channel::types::channel::Order;
use ibc_core::handler::types::error::ContextError;
use ibc_core::host::types::error::{DecodingError, IdentifierError};
use ibc_core::host::types::identifiers::{ChannelId, PortId};
use ibc_core::primitives::prelude::*;

#[derive(Display, Debug)]
#[derive(Display, Debug, derive_more::From)]
pub enum NftTransferError {
/// context error: `{0}`
ContextError(ContextError),
Expand Down Expand Up @@ -64,24 +65,6 @@ impl From<Infallible> for NftTransferError {
}
}

impl From<ContextError> for NftTransferError {
fn from(e: ContextError) -> Self {
Self::ContextError(e)
}
}

impl From<IdentifierError> for NftTransferError {
fn from(e: IdentifierError) -> Self {
Self::Identifier(e)
}
}

impl From<DecodingError> for NftTransferError {
fn from(e: DecodingError) -> Self {
Self::Decoding(e)
}
}

impl From<NftTransferError> for StatusValue {
fn from(e: NftTransferError) -> Self {
StatusValue::new(e.to_string()).expect("error message must not be empty")
Expand Down

0 comments on commit 234ebee

Please sign in to comment.