use std::io;
use serde_json::Error as SerdeError;
use thiserror::Error;
use tycho_common::simulation::errors::SimulationError;
#[derive(Debug, Error)]
pub enum InvalidSnapshotError {
#[error("Missing attributes {0}")]
MissingAttribute(String),
#[error("Value error {0}")]
ValueError(String),
#[error("Unable to set up vm state on the engine: {0}")]
VMError(SimulationError),
}
impl From<SimulationError> for InvalidSnapshotError {
fn from(error: SimulationError) -> Self {
InvalidSnapshotError::VMError(error)
}
}
impl From<FileError> for SimulationError {
fn from(error: FileError) -> Self {
SimulationError::FatalError(error.to_string())
}
}
#[derive(Debug, Error)]
pub enum FileError {
#[error("Malformed ABI error: {0}")]
MalformedABI(String),
#[error("Structure error {0}")]
Structure(String),
#[error("File path conversion error {0}")]
FilePath(String),
#[error("I/O error {0}")]
Io(io::Error),
#[error("Json parsing error {0}")]
Parse(SerdeError),
}
impl From<io::Error> for FileError {
fn from(err: io::Error) -> Self {
FileError::Io(err)
}
}
impl From<SerdeError> for FileError {
fn from(err: SerdeError) -> Self {
FileError::Parse(err)
}
}