Skip to content

Commit

Permalink
Replace iroha_error with thiserror and eyre
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Kalita <kalita.alexey@outlook.com>
  • Loading branch information
KalitaAlexey committed Sep 10, 2021
1 parent 5e5b459 commit b401d8f
Show file tree
Hide file tree
Showing 84 changed files with 386 additions and 707 deletions.
4 changes: 0 additions & 4 deletions .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ update_configs:
update_schedule: "live"
target_branch: "iroha2-dev"
directory: "iroha_error"
- package_manager: "rust:cargo"
update_schedule: "live"
target_branch: "iroha2-dev"
directory: "iroha_error/iroha_error_macro"
- package_manager: "rust:cargo"
update_schedule: "live"
target_branch: "iroha2-dev"
Expand Down
58 changes: 36 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ members = [
"iroha_data_model",
"iroha_dsl",
"iroha_error",
"iroha_error/iroha_error_macro",
"iroha_macro",
"iroha_macro/iroha_derive",
"iroha_p2p",
Expand Down
3 changes: 2 additions & 1 deletion iroha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ maintenance = { status = "actively-developed" }
iroha_data_model = { path = "../iroha_data_model", features = ["warp"] }
iroha_derive = { version = "=0.1.0", path = "../iroha_macro/iroha_derive" }
iroha_macro = { version = "=0.1.0", path = "../iroha_macro" }
iroha_error = { version = "=0.1.0", path = "../iroha_error" }
iroha_p2p = { version = "=0.1.0", path = "../iroha_p2p" }
iroha_logger = { version = "=0.1.0", path = "../iroha_logger"}
iroha_crypto = { version = "=0.1.0", path = "../iroha_crypto" }
Expand All @@ -43,6 +42,7 @@ iroha_schema = { path = "../iroha_schema"}
async-trait = "0.1"
chrono = "0.4"
dashmap = { version = "4.0" }
eyre = "0.6.5"
futures = { version = "0.3.4" }
parity-scale-codec = { version = "2", features = ["derive"] }
rand = "0.7.3"
Expand All @@ -54,6 +54,7 @@ tracing = "0.1"
warp = "0.3"
ursa = "=0.3.6"
structopt = { version = "0.3", optional = true }
thiserror = "1.0.28"

[dev-dependencies]
hex-literal = "0.2.1"
Expand Down
2 changes: 1 addition & 1 deletion iroha/docs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ edition = "2018"

[dependencies]
iroha = { path = "../../iroha" }
iroha_error = { path = "../../iroha_error" }
iroha_config = { path = "../../iroha_config" }
eyre = "0.6.5"
serde_json = "1"
4 changes: 2 additions & 2 deletions iroha/docs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use std::{
io::{stdout, BufWriter, Result, Write},
};

use eyre::Context;
use iroha::config::Configuration;
use iroha_config::Configurable;
use iroha_error::WrapErr;
use serde_json::{Map, Value};

fn main() -> iroha_error::Result<()> {
fn main() -> eyre::Result<()> {
Configuration::get_markdown(&mut BufWriter::new(stdout()))
.wrap_err("Failed to generate documentation")
}
Expand Down
2 changes: 1 addition & 1 deletion iroha/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
use std::{iter, time::SystemTime};

use dashmap::{iter::Iter as MapIter, mapref::one::Ref as MapRef, DashMap};
use eyre::Result;
use iroha_crypto::{KeyPair, Signatures};
use iroha_data_model::{events::prelude::*, transaction::prelude::*};
use iroha_derive::Io;
use iroha_error::Result;
use iroha_version::{declare_versioned_with_scale, version_with_scale};
use parity_scale_codec::{Decode, Encode};

Expand Down
2 changes: 1 addition & 1 deletion iroha/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! This module contains [`Configuration`] structure and related implementation.
use std::{fmt::Debug, fs::File, io::BufReader, path::Path};

use eyre::{Result, WrapErr};
use iroha_config::derive::Configurable;
use iroha_crypto::{KeyPair, PrivateKey, PublicKey};
use iroha_data_model::prelude::*;
use iroha_error::{Result, WrapErr};
use iroha_logger::config::LoggerConfiguration;
use serde::{Deserialize, Serialize};

Expand Down
12 changes: 6 additions & 6 deletions iroha/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use std::{convert::TryInto, fmt::Debug, time::Duration};

use eyre::{eyre, Result, WrapErr};
use futures::{SinkExt, StreamExt};
use iroha_data_model::events::{prelude::*, SubscriptionRequest};
use iroha_error::{error, Result, WrapErr};
use iroha_version::prelude::*;
use tokio::{sync::broadcast, time};
use warp::ws::{self, WebSocket};
Expand Down Expand Up @@ -39,11 +39,11 @@ impl Consumer {
let message = time::timeout(TIMEOUT, stream.next())
.await
.wrap_err("Read message timeout")?
.ok_or_else(|| error!("Failed to read message: no message"))?
.ok_or_else(|| eyre!("Failed to read message: no message"))?
.wrap_err("Web Socket failure")?;

if !message.is_binary() {
return Err(error!("Unexpected message type"));
return Err(eyre!("Unexpected message type"));
}
let SubscriptionRequest(filter): SubscriptionRequest =
VersionedEventSocketMessage::decode_versioned(message.as_bytes())?
Expand Down Expand Up @@ -85,11 +85,11 @@ impl Consumer {
let message = time::timeout(TIMEOUT, self.stream.next())
.await
.wrap_err("Failed to read receipt")?
.ok_or_else(|| error!("Failed to read receipt: no receipt"))?
.ok_or_else(|| eyre!("Failed to read receipt: no receipt"))?
.wrap_err("Web Socket failure")?;

if !message.is_binary() {
return Err(error!("Unexpected message type"));
return Err(eyre!("Unexpected message type"));
}

if let EventSocketMessage::EventReceived =
Expand All @@ -98,7 +98,7 @@ impl Consumer {
self.stream.flush().await?;
Ok(())
} else {
Err(error!("Expected `EventReceived`."))
Err(eyre!("Expected `EventReceived`."))
}
}
}
Loading

0 comments on commit b401d8f

Please sign in to comment.