A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 1fba29f99086879c95b7271428da5cf9116aba23 (755 bytes)[doc][blame][raw]
1
use std::fmt;3
use serde::Serialize;5
pub type Result<T> = std::result::Result<T, Error>;7
#[derive(Debug, Clone, Serialize)]8
pub enum ErrorKind {9
Identity,10
Arguments,11
Fetch,12
Parse,13
Query,14
}16
impl fmt::Display for ErrorKind {17
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {18
write!(f, "{:?}", self)19
}20
}22
#[derive(Debug, Clone, Serialize)]23
pub struct Error {24
kind: ErrorKind,25
message: String,26
}28
impl Error {29
pub fn new(kind: ErrorKind, message: &str) -> Self {30
Self {31
kind,32
message: message.into(),33
}34
}35
}37
impl fmt::Display for Error {38
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {39
write!(f, "[{}] {}", self.kind, self.message)40
}41
}