2019-11-26 23:54:46 +00:00
|
|
|
use crate::chunked_vector::ChunkError;
|
2020-01-08 02:58:01 +00:00
|
|
|
use crate::hot_cold_store::HotColdDBError;
|
2019-05-01 01:42:18 +00:00
|
|
|
use ssz::DecodeError;
|
2020-07-02 23:47:31 +00:00
|
|
|
use types::{BeaconStateError, Hash256, Slot};
|
2019-05-01 01:42:18 +00:00
|
|
|
|
2020-06-09 23:55:44 +00:00
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
|
2020-05-21 00:21:44 +00:00
|
|
|
#[derive(Debug)]
|
2019-05-01 01:42:18 +00:00
|
|
|
pub enum Error {
|
|
|
|
SszDecodeError(DecodeError),
|
2019-11-26 23:54:46 +00:00
|
|
|
VectorChunkError(ChunkError),
|
|
|
|
BeaconStateError(BeaconStateError),
|
|
|
|
PartialBeaconStateError,
|
2020-01-08 02:58:01 +00:00
|
|
|
HotColdDBError(HotColdDBError),
|
2019-05-01 01:42:18 +00:00
|
|
|
DBError { message: String },
|
2020-01-23 07:16:11 +00:00
|
|
|
RlpError(String),
|
2020-05-16 03:23:32 +00:00
|
|
|
BlockNotFound(Hash256),
|
2020-06-09 23:55:44 +00:00
|
|
|
NoContinuationData,
|
2020-07-02 23:47:31 +00:00
|
|
|
SplitPointModified(Slot, Slot),
|
2019-05-01 01:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<DecodeError> for Error {
|
|
|
|
fn from(e: DecodeError) -> Error {
|
|
|
|
Error::SszDecodeError(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-26 23:54:46 +00:00
|
|
|
impl From<ChunkError> for Error {
|
|
|
|
fn from(e: ChunkError) -> Error {
|
|
|
|
Error::VectorChunkError(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 02:58:01 +00:00
|
|
|
impl From<HotColdDBError> for Error {
|
|
|
|
fn from(e: HotColdDBError) -> Error {
|
|
|
|
Error::HotColdDBError(e)
|
2019-11-26 23:54:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 }
|
|
|
|
}
|
|
|
|
}
|