Skip to content

Commit

Permalink
fix(inx): better error reporting (#479)
Browse files Browse the repository at this point in the history
* fix(inx): better error reporting

* Fmt
  • Loading branch information
grtlr authored Jul 27, 2022
1 parent 44aece3 commit 14329b6
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions bin/inx-chronicle/src/stardust_inx/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,26 @@ pub enum InxError {
ConnectionError,
#[error("expected INX address with format `http://<address>:<port>`, but found `{0}`")]
InvalidAddress(String),
#[error("INX type conversion error: {0:?}")]
InxTypeConversion(#[from] bee_block_stardust::InxError),
#[error("missing milestone id for milestone index `{0}`")]
MissingMilestoneInfo(MilestoneIndex),
#[error(transparent)]
#[error("MongoDB error: {0}")]
MongoDb(#[from] mongodb::error::Error),
#[error("network changed from previous run. old network name: {0}, new network name: {1}")]
NetworkChanged(String, String),
#[error(transparent)]
ParsingAddressFailed(#[from] url::ParseError),
#[error(transparent)]
Runtime(#[from] chronicle::runtime::RuntimeError),
#[error(transparent)]
#[error("INX error: {0}")]
BeeInx(#[from] bee_inx::Error),
}

impl ErrorLevel for InxError {
fn level(&self) -> log::Level {
match self {
Self::InvalidAddress(_)
| Self::InxTypeConversion(_)
| Self::MongoDb(_)
| Self::NetworkChanged(_, _)
| Self::ParsingAddressFailed(_) => log::Level::Error,
Self::InvalidAddress(_) | Self::MongoDb(_) | Self::NetworkChanged(_, _) | Self::ParsingAddressFailed(_) => {
log::Level::Error
}
_ => log::Level::Warn,
}
}
Expand Down

0 comments on commit 14329b6

Please sign in to comment.