A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 34d0df34f733294cfe587f18ac553315642270ea (1012 bytes)[doc][blame][raw]
1
use serde::Serialize;2
use std::fmt;4
#[derive(Debug, Clone, Serialize)]5
pub struct Error {6
message: String,7
}9
impl Error {10
#[must_use]11
pub fn new(message: &str) -> Self {12
Self {13
message: message.into(),14
}15
}16
}18
impl fmt::Display for Error {19
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {20
write!(f, "{}", self.message)21
}22
}24
impl From<std::io::Error> for Error {25
fn from(err: std::io::Error) -> Self {26
Self::new(&err.to_string())27
}28
}30
impl From<std::fmt::Error> for Error {31
fn from(err: std::fmt::Error) -> Self {32
Self::new(&err.to_string())33
}34
}36
impl From<toml::de::Error> for Error {37
fn from(err: toml::de::Error) -> Self {38
Self::new(&err.to_string())39
}40
}42
impl From<sqlx::Error> for Error {43
fn from(err: sqlx::Error) -> Self {44
Self::new(&err.to_string())45
}46
}48
impl From<tide::Error> for Error {49
fn from(err: tide::Error) -> Self {50
Self::new(&err.to_string())51
}52
}