Files
tycho-execution/src/encoding/errors.rs
Diana Carvalho 1a8e0f102c chore: Make objects public
Remove dead_code check and leftover file after a merge
Improve some docstrings

--- don't change below this line ---
ENG-4087 Took 1 hour 39 minutes
2025-01-31 18:40:59 +00:00

36 lines
1.2 KiB
Rust

use std::io;
use thiserror::Error;
/// Represents the outer-level, user-facing errors of the tycho-execution encoding package.
///
/// `EncodingError` encompasses all possible errors that can occur in the package,
/// wrapping lower-level errors in a user-friendly way for easier handling and display.
/// Variants:
/// - `InvalidInput`: Indicates that the encoding has failed due to bad input parameters.
/// - `FatalError`: There is problem with the application setup.
/// - `RecoverableError`: Indicates that the encoding has failed with a recoverable error. Retrying
/// at a later time may succeed. It may have failed due to a temporary issue, such as a network
/// problem.
#[derive(Error, Debug, PartialEq)]
pub enum EncodingError {
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("Fatal error: {0}")]
FatalError(String),
#[error("Recoverable error: {0}")]
RecoverableError(String),
}
impl From<io::Error> for EncodingError {
fn from(err: io::Error) -> Self {
EncodingError::FatalError(err.to_string())
}
}
impl From<serde_json::Error> for EncodingError {
fn from(err: serde_json::Error) -> Self {
EncodingError::FatalError(err.to_string())
}
}