use thiserror::Error;
use casper_execution_engine::engine_state;
use casper_types::{bytesrepr, crypto::ErrorExt as CryptoError};
use crate::{
components::{
binary_port::BinaryPortInitializationError,
contract_runtime::{self, BlockExecutionError},
diagnostics_port, network, storage, upgrade_watcher,
},
utils::{ListeningError, LoadError},
};
#[derive(Debug, Error)]
pub(crate) enum Error {
#[error("upgrade watcher error: {0}")]
UpgradeWatcher(#[from] upgrade_watcher::Error),
#[error("prometheus (metrics) error: {0}")]
Metrics(#[from] prometheus::Error),
#[error("network error: {0}")]
Network(#[from] network::Error),
#[error("http server listening error: {0}")]
HttpServerListening(#[from] ListeningError),
#[error("storage error: {0}")]
Storage(#[from] storage::FatalStorageError),
#[error("consensus error: {0}")]
Consensus(#[from] anyhow::Error),
#[error("contract runtime config error: {0}")]
ContractRuntime(#[from] contract_runtime::ConfigError),
#[error(transparent)]
BlockExecution(#[from] BlockExecutionError),
#[error(transparent)]
EngineState(#[from] engine_state::Error),
#[error("bytesrepr error: {0}")]
BytesRepr(bytesrepr::Error),
#[error("diagnostics port: {0}")]
DiagnosticsPort(#[from] diagnostics_port::Error),
#[error("signing key pair load error: {0}")]
LoadSigningKeyPair(#[from] LoadError<CryptoError>),
#[error("binary port: {0}")]
BinaryPort(#[from] BinaryPortInitializationError),
}
impl From<bytesrepr::Error> for Error {
fn from(err: bytesrepr::Error) -> Self {
Self::BytesRepr(err)
}
}