1use diem_crypto::HashValue;
9use serde::{Deserialize, Serialize};
10use thiserror::Error;
11
12#[derive(Debug, Deserialize, Error, PartialEq, Serialize)]
13pub enum Error {
15 #[error("Cannot find speculation result for block id {0}")]
16 BlockNotFound(HashValue),
17
18 #[error("Internal error: {:?}", error)]
19 InternalError { error: String },
20
21 #[error("Serialization error: {0}")]
22 SerializationError(String),
23}
24
25impl From<anyhow::Error> for Error {
26 fn from(error: anyhow::Error) -> Self {
27 Self::InternalError {
28 error: format!("{}", error),
29 }
30 }
31}
32
33impl From<bcs::Error> for Error {
34 fn from(error: bcs::Error) -> Self {
35 Self::SerializationError(format!("{}", error))
36 }
37}
38
39impl From<diem_secure_net::Error> for Error {
40 fn from(error: diem_secure_net::Error) -> Self {
41 Self::InternalError {
42 error: format!("{}", error),
43 }
44 }
45}