lighthouse/beacon_node/store/src/errors.rs

62 lines
1.3 KiB
Rust
Raw Normal View History

use crate::chunked_vector::ChunkError;
use crate::hot_cold_store::HotColdDBError;
2019-05-01 01:42:18 +00:00
use ssz::DecodeError;
use types::{BeaconStateError, Hash256, Slot};
2019-05-01 01:42:18 +00:00
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
2019-05-01 01:42:18 +00:00
pub enum Error {
SszDecodeError(DecodeError),
VectorChunkError(ChunkError),
BeaconStateError(BeaconStateError),
PartialBeaconStateError,
HotColdDBError(HotColdDBError),
2019-05-01 01:42:18 +00:00
DBError { message: String },
RlpError(String),
BlockNotFound(Hash256),
NoContinuationData,
SplitPointModified(Slot, Slot),
2019-05-01 01:42:18 +00:00
}
impl From<DecodeError> for Error {
fn from(e: DecodeError) -> Error {
Error::SszDecodeError(e)
}
}
impl From<ChunkError> for Error {
fn from(e: ChunkError) -> Error {
Error::VectorChunkError(e)
}
}
impl From<HotColdDBError> for Error {
fn from(e: HotColdDBError) -> Error {
Error::HotColdDBError(e)
}
}
impl From<BeaconStateError> for Error {
fn from(e: BeaconStateError) -> Error {
Error::BeaconStateError(e)
}
}
2019-05-01 01:42:18 +00:00
impl From<DBError> 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 }
}
}