rustfm_scrobble_proxy/
error.rs1use std::error::Error as StdError;
2use std::fmt;
3use std::time::SystemTimeError;
4
5#[derive(Debug)]
13pub struct ScrobblerError {
14 err_msg: String,
15}
16
17impl ScrobblerError {
18 pub fn new(err_msg: String) -> Self {
19 ScrobblerError { err_msg }
20 }
21}
22
23impl fmt::Display for ScrobblerError {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 write!(f, "{}", self.err_msg)
26 }
27}
28
29impl StdError for ScrobblerError {}
30
31impl From<SystemTimeError> for ScrobblerError {
32 fn from(error: SystemTimeError) -> Self {
33 Self::new(error.to_string())
34 }
35}
36
37impl From<String> for ScrobblerError {
38 fn from(error: String) -> Self {
39 Self::new(error)
40 }
41}