1use std::fmt;
2
3pub type Result<T> = std::result::Result<T, PlayerError>;
5
6#[derive(Debug)]
8pub enum PlayerError {
9 NoOutputDevice,
11 DeviceInitFailed(String),
13 PlaybackFailed(String),
15 BackendError(String),
17}
18
19impl fmt::Display for PlayerError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 PlayerError::NoOutputDevice => write!(f, "No audio output device available"),
23 PlayerError::DeviceInitFailed(msg) => write!(f, "Failed to initialize audio device: {msg}"),
24 PlayerError::PlaybackFailed(msg) => write!(f, "Playback failed: {msg}"),
25 PlayerError::BackendError(msg) => write!(f, "Backend error: {msg}"),
26 }
27 }
28}
29
30impl std::error::Error for PlayerError {}