Skip to content

Commit

Permalink
refactor(blueprint-manager): lots of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Dec 27, 2024
1 parent 71072ab commit c44f3cc
Show file tree
Hide file tree
Showing 24 changed files with 432 additions and 476 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/blueprint/manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ reqwest = { workspace = true }
sha2 = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
thiserror.workspace = true
tracing = { workspace = true, features = ["log"] }
tracing-subscriber = { workspace = true, features = ["env-filter", "ansi", "tracing-log"] }
libp2p = { workspace = true }
Expand Down
57 changes: 33 additions & 24 deletions crates/blueprint/manager/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
use std::fmt::{Display, Formatter};
pub type Result<T> = std::result::Result<T, Error>;

#[derive(Debug, Clone)]
pub struct Error {
pub message: String,
}
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("No fetchers found for blueprint")]
NoFetchers,
#[error("Multiple fetchers found for blueprint")]
MultipleFetchers,
#[error("No testing fetcher found for blueprint, despite operating in test mode")]
NoTestFetcher,
#[error("Blueprint does not contain a supported fetcher")]
UnsupportedGadget,

impl Error {
pub fn msg<T: Into<String>>(msg: T) -> Self {
Self {
message: msg.into(),
}
}
}
#[error("Unable to find matching binary")]
NoMatchingBinary,
#[error("Binary hash {expected} mismatched expected hash of {actual}")]
HashMismatch { expected: String, actual: String },
#[error("Failed to build binary: {0:?}")]
BuildBinary(std::process::Output),
#[error("Failed to fetch git root: {0:?}")]
FetchGitRoot(std::process::Output),

impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
std::fmt::Debug::fmt(self, f)
}
}
#[error("Failed to get initial block hash")]
InitialBlock,
#[error("Finality Notification stream died")]
ClientDied,
#[error("{0}")]
Other(String),

impl std::error::Error for Error {}
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Utf8(#[from] std::string::FromUtf8Error),

impl From<std::io::Error> for Error {
fn from(error: std::io::Error) -> Self {
Error {
message: error.to_string(),
}
}
#[error(transparent)]
Request(#[from] reqwest::Error),
#[error(transparent)]
TangleClient(#[from] gadget_clients::tangle::error::Error),
}
Loading

0 comments on commit c44f3cc

Please sign in to comment.