mirror of
https://github.com/nimbold/Firelink.git
synced 2026-07-26 12:08:27 +00:00
34 lines
707 B
Rust
34 lines
707 B
Rust
use serde::Serialize;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Error, Debug)]
|
|
pub enum AppError {
|
|
#[error("IO error: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
#[error("Network error: {0}")]
|
|
Reqwest(#[from] reqwest::Error),
|
|
#[error("Internal error: {0}")]
|
|
Internal(String),
|
|
}
|
|
|
|
impl Serialize for AppError {
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
where
|
|
S: serde::Serializer,
|
|
{
|
|
serializer.serialize_str(&self.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<String> for AppError {
|
|
fn from(s: String) -> Self {
|
|
AppError::Internal(s)
|
|
}
|
|
}
|
|
|
|
impl From<&str> for AppError {
|
|
fn from(s: &str) -> Self {
|
|
AppError::Internal(s.to_string())
|
|
}
|
|
}
|