use crate::chunked_vector::ChunkError; use crate::hot_cold_store::HotColdDBError; use ssz::DecodeError; use types::{BeaconStateError, Hash256, Slot}; pub type Result = std::result::Result; #[derive(Debug)] pub enum Error { SszDecodeError(DecodeError), VectorChunkError(ChunkError), BeaconStateError(BeaconStateError), PartialBeaconStateError, HotColdDBError(HotColdDBError), DBError { message: String }, RlpError(String), BlockNotFound(Hash256), NoContinuationData, SplitPointModified(Slot, Slot), } impl From for Error { fn from(e: DecodeError) -> Error { Error::SszDecodeError(e) } } impl From for Error { fn from(e: ChunkError) -> Error { Error::VectorChunkError(e) } } impl From for Error { fn from(e: HotColdDBError) -> Error { Error::HotColdDBError(e) } } impl From for Error { fn from(e: BeaconStateError) -> Error { Error::BeaconStateError(e) } } impl From for Error { fn from(e: DBError) -> Error { Error::DBError { message: e.message } } } #[derive(Debug)] pub struct DBError { pub message: String, } impl DBError { pub fn new(message: String) -> Self { Self { message } } }