-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use flex-error to define errors (#988)
- Loading branch information
1 parent
1824735
commit b18f33f
Showing
166 changed files
with
5,351 additions
and
3,947 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 43 additions & 41 deletions
84
modules/src/application/ics20_fungible_token_transfer/error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,46 @@ | ||
use anomaly::{BoxError, Context}; | ||
use thiserror::Error; | ||
|
||
use crate::ics04_channel::error as channel_error; | ||
use crate::ics24_host::error::ValidationError; | ||
use crate::ics24_host::identifier::{ChannelId, PortId}; | ||
|
||
pub type Error = anomaly::Error<Kind>; | ||
|
||
#[derive(Clone, Debug, Error, PartialEq, Eq)] | ||
pub enum Kind { | ||
#[error("unrecognized ICS-20 transfer message type URL {0}")] | ||
UnknownMessageTypeUrl(String), | ||
|
||
#[error("error raised by message handler")] | ||
HandlerRaisedError, | ||
|
||
#[error("sending sequence number not found for port {0} and channel {1}")] | ||
SequenceSendNotFound(PortId, ChannelId), | ||
|
||
#[error("missing channel for port_id {0} and channel_id {1} ")] | ||
ChannelNotFound(PortId, ChannelId), | ||
|
||
#[error( | ||
"destination channel not found in the counterparty of port_id {0} and channel_id {1} " | ||
)] | ||
DestinationChannelNotFound(PortId, ChannelId), | ||
|
||
#[error("invalid port identifier")] | ||
InvalidPortId(String), | ||
|
||
#[error("invalid channel identifier")] | ||
InvalidChannelId(String), | ||
|
||
#[error("invalid packet timeout height value")] | ||
InvalidPacketTimeoutHeight(String), | ||
|
||
#[error("invalid packet timeout timestamp value")] | ||
InvalidPacketTimeoutTimestamp(u64), | ||
} | ||
|
||
impl Kind { | ||
pub fn context(self, source: impl Into<BoxError>) -> Context<Self> { | ||
Context::new(self, Some(source.into())) | ||
use flex_error::define_error; | ||
|
||
define_error! { | ||
Error { | ||
UnknowMessageTypeUrl | ||
{ url: String } | ||
| e | { format_args!("unrecognized ICS-20 transfer message type URL {0}", e.url) }, | ||
|
||
Ics04Channel | ||
[ channel_error::Error ] | ||
|_ | { "Ics04 channel error" }, | ||
|
||
SequenceSendNotFound | ||
{ port_id: PortId, channel_id: ChannelId } | ||
| e | { format_args!("sending sequence number not found for port {0} and channel {1}", e.port_id, e.channel_id) }, | ||
|
||
ChannelNotFound | ||
{ port_id: PortId, channel_id: ChannelId } | ||
| e | { format_args!("sending sequence number not found for port {0} and channel {1}", e.port_id, e.channel_id) }, | ||
|
||
DestinationChannelNotFound | ||
{ port_id: PortId, channel_id: ChannelId } | ||
| e | { format_args!("destination channel not found in the counterparty of port_id {0} and channel_id {1} ", e.port_id, e.channel_id) }, | ||
|
||
InvalidPortId | ||
{ context: String } | ||
[ ValidationError ] | ||
| _ | { "invalid port identifier" }, | ||
|
||
InvalidChannelId | ||
{ context: String } | ||
[ ValidationError ] | ||
| _ | { "invalid channel identifier" }, | ||
|
||
InvalidPacketTimeoutHeight | ||
{ context: String } | ||
| _ | { "invalid packet timeout height value" }, | ||
|
||
InvalidPacketTimeoutTimestamp | ||
{ timestamp: u64 } | ||
| _ | { "invalid packet timeout timestamp value" }, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.