use diesel::result::Error as DslError; use reqwest::Error as ReqError; use serde::{Deserialize, Serialize}; use thiserror::Error; use uuid::Uuid; pub type UResult = std::result::Result; pub type ULocalResult = std::result::Result; #[derive(Error, Debug, Serialize, Deserialize, Clone)] pub enum UError { #[error("Error: {0}")] Raw(&'static str), #[error("Connection error: {0}. Body: {1}")] NetError(String, String), #[error("Parse error")] ParseError, #[error("Job error: {0}")] JobError(String), #[error("Job is uncompleted yet")] JobUncompleted, #[error("Job cannot be ran on this platform. Expected: {0}, got: {1}")] InsuitablePlatform(String, String), #[error("Job {0} doesn't exist")] NoJob(Uuid), #[error("Error opening {0}: {1}")] FilesystemError(String, String), } impl From for UError { fn from(e: ReqError) -> Self { UError::NetError(e.to_string(), String::new()) } } #[derive(Error, Debug)] pub enum ULocalError { #[error("{0} is not found")] NotFound(String), #[error("Error processing {0}")] ProcessingError(String), #[error(transparent)] DBError(#[from] DslError), }