2024-04-30 17:39:33 +02:00
|
|
|
//! Library specific error messages.
|
|
|
|
|
2024-05-03 22:29:25 +02:00
|
|
|
use thiserror::Error;
|
|
|
|
use serde_json::{Map, Value};
|
2024-04-30 17:39:33 +02:00
|
|
|
|
2024-05-03 22:29:25 +02:00
|
|
|
use crate::MpvDataType;
|
2024-04-30 17:39:33 +02:00
|
|
|
|
2024-05-03 22:29:25 +02:00
|
|
|
/// Any error that can occur when interacting with mpv.
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum MpvError {
|
|
|
|
#[error("MpvError: {0}")]
|
2024-04-30 17:39:33 +02:00
|
|
|
MpvError(String),
|
|
|
|
|
2024-05-03 22:29:25 +02:00
|
|
|
#[error("Error communicating over mpv socket: {0}")]
|
|
|
|
MpvSocketConnectionError(String),
|
|
|
|
|
|
|
|
#[error("Internal connection error: {0}")]
|
|
|
|
InternalConnectionError(String),
|
|
|
|
|
|
|
|
#[error("JsonParseError: {0}")]
|
|
|
|
JsonParseError(#[from] serde_json::Error),
|
|
|
|
|
|
|
|
#[error("Mpv sent a value with an unexpected type:\nExpected {expected_type}, received {received:#?}")]
|
|
|
|
ValueContainsUnexpectedType {
|
|
|
|
expected_type: String,
|
|
|
|
received: Value,
|
|
|
|
},
|
|
|
|
|
|
|
|
#[error("Mpv sent data with an unexpected type:\nExpected {expected_type}, received {received:#?}")]
|
|
|
|
DataContainsUnexpectedType {
|
|
|
|
expected_type: String,
|
|
|
|
received: MpvDataType,
|
|
|
|
},
|
2024-04-30 17:39:33 +02:00
|
|
|
|
2024-05-03 22:29:25 +02:00
|
|
|
#[error("Missing expected 'data' field in mpv message")]
|
|
|
|
MissingMpvData,
|
2024-04-30 17:39:33 +02:00
|
|
|
|
2024-05-03 22:29:25 +02:00
|
|
|
#[error("Missing key in object:\nExpected {key} in {map:#?}")]
|
|
|
|
MissingKeyInObject {
|
|
|
|
key: String,
|
|
|
|
map: Map<String, Value>,
|
|
|
|
},
|
2024-04-30 17:39:33 +02:00
|
|
|
|
2024-05-03 22:29:25 +02:00
|
|
|
#[error("Unknown error: {0}")]
|
|
|
|
Other(String),
|
|
|
|
}
|