#![deny(clippy::arithmetic_side_effects)]
#![deny(clippy::cast_possible_truncation)]
#![deny(missing_docs)]
#![deny(unused_crate_dependencies)]
#![deny(warnings)]
#![deny(unused_variables)]
use fuel_core_storage::Error as StorageError;
use fuel_core_types::services::executor::Error as ExecutorError;
use std::array::TryFromSliceError;
#[derive(Debug, derive_more::Display, derive_more::From)]
#[non_exhaustive]
pub enum Error {
#[display(fmt = "error performing serialization or deserialization")]
Codec,
#[display(fmt = "Failed to initialize chain")]
ChainAlreadyInitialized,
#[display(fmt = "Chain is not yet initialized")]
ChainUninitialized,
#[display(
fmt = "Invalid database version, expected {expected:#x}, found {found:#x}"
)]
InvalidDatabaseVersion {
found: u32,
expected: u32,
},
#[from]
Other(anyhow::Error),
}
impl From<Error> for anyhow::Error {
fn from(error: Error) -> Self {
anyhow::Error::msg(error)
}
}
impl From<Error> for StorageError {
fn from(e: Error) -> Self {
StorageError::DatabaseError(Box::new(e))
}
}
impl From<TryFromSliceError> for Error {
fn from(e: TryFromSliceError) -> Self {
Self::Other(anyhow::anyhow!(e))
}
}
impl From<Error> for ExecutorError {
fn from(e: Error) -> Self {
ExecutorError::StorageError(anyhow::anyhow!(StorageError::from(e)))
}
}
#[cfg(test)]
fuel_core_trace::enable_tracing!();