use thiserror::Error;

#[derive(Debug, Error)]
pub enum DatabaseError {
  #[error("Database initialization failed: {0}")]
  Init(#[from] std::io::Error),
  #[error("Database operation failed: {0}")]
  Operation(#[from] sled::Error),
  #[error("Failed to serialize data: {0}")]
  Encode(#[from] bincode::error::EncodeError),
  #[error("Failed to deserialize data: {0}")]
  Decode(#[from] bincode::error::DecodeError),
  #[error("Chain data not found for hash: {0}")]
  MissingData(String),
  #[error("Account already exists: {0}")]
  AccountExists(String),
  #[error("Account does not exist: {0}")]
  AccountNotFound(String),
  #[error("Database corruption detected: {0}")]
  Corruption(String),
}
