A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 5f1bc536e251b8611c3963f502164f9cd40a0921 (744 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
}15
impl fmt::Display for ErrorKind {16
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {17
write!(f, "{:?}", self)18
}19
}21
#[derive(Debug, Clone, Serialize)]22
pub struct Error {23
kind: ErrorKind,24
message: String,25
}27
impl Error {28
pub fn new(kind: ErrorKind, message: &str) -> Self {29
Self {30
kind,31
message: message.into(),32
}33
}34
}36
impl fmt::Display for Error {37
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {38
write!(f, "[{}] {}", self.kind, self.message)39
}40
}