apple_music/
error.rs

1use std::borrow::Cow;
2use std::fmt;
3use std::fmt::{Display, Formatter};
4
5#[derive(Debug)]
6pub enum Error {
7    NotPlaying,
8    NoData,
9    DeserializationFailed,
10    AppCommandFailed,
11}
12
13impl Display for Error {
14    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
15        let msg = match self {
16            Error::NotPlaying => Cow::Borrowed("Failed to convert values"),
17            Error::NoData => Cow::Borrowed("Failed to get current_track Data!"),
18            Error::DeserializationFailed => {
19                Cow::Borrowed("Failed to deserialize current_track Data!")
20            }
21            Error::AppCommandFailed => Cow::Borrowed("Failed to execute AppCommand"),
22        };
23
24        f.write_str(&msg)
25    }
26}