use diem_crypto::HashValue;
use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Debug, Deserialize, Error, PartialEq, Serialize)]
pub enum Error {
#[error("Cannot find speculation result for block id {0}")]
BlockNotFound(HashValue),
#[error("Internal error: {:?}", error)]
InternalError { error: String },
#[error("Serialization error: {0}")]
SerializationError(String),
}
impl From<anyhow::Error> for Error {
fn from(error: anyhow::Error) -> Self {
Self::InternalError {
error: format!("{}", error),
}
}
}
impl From<bcs::Error> for Error {
fn from(error: bcs::Error) -> Self {
Self::SerializationError(format!("{}", error))
}
}
impl From<diem_secure_net::Error> for Error {
fn from(error: diem_secure_net::Error) -> Self {
Self::InternalError {
error: format!("{}", error),
}
}
}