Lines
0 %
Functions
use std::fmt::Display;
use serde::{Deserialize, Serialize};
use thiserror::Error;
pub type Response = Result<(), MpdError>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ErrorCode {
// NOTE: seemingly unused
NotList = 1,
Arg = 2,
// NOTE: only used for 'password' command
Password = 3,
Permission = 4,
// NOTE: Catchall error
Unknown = 5,
NoExist = 50,
PlaylistMax = 51,
System = 52,
PlaylistLoad = 53,
UpdateAlready = 54,
PlayerSync = 55,
Exist = 56,
}
#[derive(Error, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct MpdError {
code: ErrorCode,
command: String,
message: String,
command_list_num: usize,
impl Display for MpdError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"MPD Error (code: {:?}, command: '{}', message: '{}', command_list_num: {})",
self.code, self.command, self.message, self.command_list_num
)