Skip to content

Commit

Permalink
Include cause in Failed errors (#555). Double-checking 'required' tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
adizere committed Jan 26, 2021
1 parent 9d0a7b8 commit 72242cf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
6 changes: 3 additions & 3 deletions relayer-cli/src/commands/query/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ use crate::prelude::*;

#[derive(Clone, Command, Debug, Options)]
pub struct QueryChannelEndCmd {
#[options(free, help = "identifier of the chain to query")]
#[options(free, required, help = "identifier of the chain to query")]
chain_id: Option<ChainId>,

#[options(free, help = "identifier of the port to query")]
#[options(free, required, help = "identifier of the port to query")]
port_id: Option<String>,

#[options(free, help = "identifier of the channel to query")]
#[options(free, required, help = "identifier of the channel to query")]
channel_id: Option<String>,

#[options(help = "height of the state to query", short = "h")]
Expand Down
4 changes: 2 additions & 2 deletions relayer-cli/src/commands/query/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ use crate::prelude::*;
/// Query client state command
#[derive(Clone, Command, Debug, Options)]
pub struct QueryClientStateCmd {
#[options(free, help = "identifier of the chain to query")]
#[options(free, required, help = "identifier of the chain to query")]
chain_id: Option<ChainId>,

#[options(free, help = "identifier of the client to query")]
#[options(free, required, help = "identifier of the client to query")]
client_id: Option<String>,

#[options(help = "the chain height which this query should reflect", short = "h")]
Expand Down
9 changes: 5 additions & 4 deletions relayer-cli/src/commands/tx/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ use crate::prelude::*;

#[derive(Clone, Command, Debug, Options)]
pub struct TxRawSendPacketCmd {
#[options(free, help = "identifier of the source chain")]
#[options(free, required, help = "identifier of the source chain")]
src_chain_id: ChainId,

#[options(free, help = "identifier of the destination chain")]
#[options(free, required, help = "identifier of the destination chain")]
dest_chain_id: ChainId,

#[options(free, help = "identifier of the source port")]
#[options(free, required, help = "identifier of the source port")]
src_port_id: PortId,

#[options(free, help = "identifier of the source channel")]
#[options(free, required, help = "identifier of the source channel")]
src_channel_id: ChannelId,

#[options(
free,
required,
help = "amount of coins (samoleans, by default) to send (e.g. `100000`)"
)]
amount: u64,
Expand Down
12 changes: 12 additions & 0 deletions relayer-cli/src/conclude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
//! Output::error(format!("{}", e)).exit();
//! ```
//!
//! #### Note:
//! The resulting output that this approach generates is determined by the 'error' annotation given
//! to the error object `Kind::Query`. If this error object comprises any positional arguments,
//! e.g. as achieved by `Query(String, String)`, then it is important to cover these arguments
//! in the `error` annotation, for instance:
//! ```compile_fail
//! #[derive(Debug, Error)]
//! pub enum Kind {
//! #[error("failed with underlying causes: {0}, {1}")]
//! Query(String, String), // ...
//! ```
//!
//! - Exit from a query/tx with success:
//!
//! ```compile_fail
Expand Down
2 changes: 1 addition & 1 deletion relayer/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::relay::MAX_ITER;

#[derive(Debug, Error)]
pub enum ChannelError {
#[error("failed")]
#[error("failed with underlying cause: {0}")]
Failed(String),

#[error("failed during an operation on client ({0}) hosted by chain ({1}) with error: {2}")]
Expand Down
4 changes: 2 additions & 2 deletions relayer/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ use crate::relay::MAX_ITER;

#[derive(Debug, Error)]
pub enum ConnectionError {
#[error("Failed")]
#[error("failed with underlying cause: {0}")]
Failed(String),

#[error("constructor parameters do not match")]
#[error("constructor parameters do not match: underlying error: {0}")]
ConstructorFailed(String),

#[error("failed during a query to chain id {0} due to underlying error: {1}")]
Expand Down

0 comments on commit 72242cf

Please sign in to comment.