tycho_simulation/protocol/
errors.rs1use std::io;
3
4use serde_json::Error as SerdeError;
5use thiserror::Error;
6use tycho_common::simulation::errors::SimulationError;
7
8#[derive(Debug, Error)]
9pub enum InvalidSnapshotError {
10 #[error("Missing attributes {0}")]
11 MissingAttribute(String),
12 #[error("Value error {0}")]
13 ValueError(String),
14 #[error("Unable to set up vm state on the engine: {0}")]
15 VMError(SimulationError),
16}
17
18impl From<SimulationError> for InvalidSnapshotError {
19 fn from(error: SimulationError) -> Self {
20 InvalidSnapshotError::VMError(error)
21 }
22}
23
24impl From<FileError> for SimulationError {
25 fn from(error: FileError) -> Self {
26 SimulationError::FatalError(error.to_string())
27 }
28}
29
30#[derive(Debug, Error)]
31pub enum FileError {
32 #[error("Malformed ABI error: {0}")]
34 MalformedABI(String),
35 #[error("Structure error {0}")]
37 Structure(String),
38 #[error("File path conversion error {0}")]
40 FilePath(String),
41 #[error("I/O error {0}")]
42 Io(io::Error),
43 #[error("Json parsing error {0}")]
44 Parse(SerdeError),
45}
46
47impl From<io::Error> for FileError {
48 fn from(err: io::Error) -> Self {
49 FileError::Io(err)
50 }
51}
52
53impl From<SerdeError> for FileError {
54 fn from(err: SerdeError) -> Self {
55 FileError::Parse(err)
56 }
57}