|
|
|
use reqwest::Error as ReqError;
|
|
|
|
use serde::{
|
|
|
|
Serialize,
|
|
|
|
Deserialize
|
|
|
|
};
|
|
|
|
use thiserror::Error;
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
|
|
pub type UResult<T> = std::result::Result<T, UError>;
|
|
|
|
|
|
|
|
#[derive(Error, Debug, Serialize, Deserialize, Clone)]
|
|
|
|
pub enum UError {
|
|
|
|
#[error("Error: {0}")]
|
|
|
|
Raw(&'static str),
|
|
|
|
|
|
|
|
#[error("Connection error: {0}")]
|
|
|
|
NetError(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("Task {0} doesn't exist")]
|
|
|
|
NoTask(Uuid)
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ReqError> for UError {
|
|
|
|
fn from(e: ReqError) -> Self {
|
|
|
|
UError::NetError(e.to_string())
|
|
|
|
}
|
|
|
|
}
|