use blueprint_core::error::BoxError;
use thiserror::Error;
use tokio::task::JoinError;
#[derive(Error, Debug)]
pub enum RunnerError {
#[error("Keystore error: {0}")]
Keystore(#[from] blueprint_keystore::Error),
#[error("Bridge error: {0}")]
Bridge(#[from] blueprint_manager_bridge::Error),
#[cfg(feature = "networking")]
#[error("Networking error: {0}")]
Networking(#[from] blueprint_networking::error::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error(transparent)]
AddrParse(#[from] std::net::AddrParseError),
#[error("QoS error: {0}")]
QoS(#[from] blueprint_qos::error::Error),
#[error("Configuration error: {0}")]
Config(#[from] ConfigError),
#[error("Blueprint runner configured without a router")]
NoRouter,
#[error("Blueprint runner configured without any producers")]
NoProducers,
#[error("A background service failed: {0}")]
BackgroundService(String),
#[error("A job call failed: {0}")]
JobCall(#[from] JobCallError),
#[error("A producer failed: {0}")]
Producer(#[from] ProducerError),
#[error("A consumer failed: {0}")]
Consumer(BoxError),
#[cfg(feature = "tangle")]
#[error("Tangle error: {0}")]
Tangle(#[from] crate::tangle::error::TangleError),
#[cfg(feature = "eigenlayer")]
#[error("EigenLayer error: {0}")]
Eigenlayer(#[from] crate::eigenlayer::error::EigenlayerError),
#[error("{0}")]
Other(#[from] Box<dyn core::error::Error + Send + Sync>),
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum ConfigError {
#[error("Invalid argument: {0}")]
InvalidArgument(String),
#[error("Missing keystore URI")]
MissingKeystoreUri,
#[error("Missing blueprint ID")]
MissingBlueprintId,
#[error("Missing service ID")]
MissingServiceId,
#[error(transparent)]
MalformedBlueprintId(core::num::ParseIntError),
#[error(transparent)]
MalformedServiceId(core::num::ParseIntError),
#[error("Unsupported keystore URI: {0}")]
UnsupportedKeystoreUri(String),
#[error("Unexpect protocol, expected {0}")]
UnexpectedProtocol(&'static str),
#[error("No ECDSA keypair found in the keystore")]
NoEcdsaKeypair,
#[error("Invalid ECDSA keypair found in the keystore")]
InvalidEcdsaKeypair,
#[error("Test setup error: {0}")]
TestSetup(String),
#[error("Missing EigenlayerContractAddresses")]
MissingEigenlayerContractAddresses,
#[error("Missing SymbioticContractAddresses")]
MissingSymbioticContractAddresses,
#[cfg(feature = "tls")]
#[error("Missing TLS configuration: {0}")]
MissingTlsConfig(String),
#[cfg(feature = "tls")]
#[error("Invalid TLS configuration: {0}")]
InvalidTlsConfig(String),
#[cfg(feature = "tls")]
#[error("IO error: {0}")]
IoError(String),
#[error("{0}")]
Other(#[from] Box<dyn core::error::Error + Send + Sync>),
}
#[derive(Error, Debug)]
pub enum JobCallError {
#[error("Job call failed: {0}")]
JobFailed(Box<dyn core::error::Error + Send + Sync>),
#[error("Job failed to finish: {0}")]
JobDidntFinish(JoinError),
}
#[derive(Error, Debug)]
pub enum ProducerError {
#[error("A producer failed to produce a value: {0}")]
Failed(Box<dyn core::error::Error + Send + Sync>),
#[error("A producer stream ended unexpectedly")]
StreamEnded,
}