traxor/src/error.rs
Kristofers Solo be542551f3
Some checks failed
CI / build-and-test (push) Has been cancelled
refactor: add custom error type
2025-12-10 03:57:28 +02:00

31 lines
719 B
Rust

use thiserror::Error;
#[derive(Debug, Error)]
pub enum TraxorError {
#[error("Transmission RPC error: {0}")]
TransmissionRpc(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("URL parse error: {0}")]
UrlParse(#[from] url::ParseError),
#[error("No torrent selected")]
NoSelection,
#[error("Invalid torrent ID: {0}")]
InvalidTorrentId(i64),
}
impl From<Box<dyn std::error::Error + Send + Sync>> for TraxorError {
fn from(e: Box<dyn std::error::Error + Send + Sync>) -> Self {
Self::TransmissionRpc(e.to_string())
}
}
pub type Result<T> = std::result::Result<T, TraxorError>;