1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
use crate::SettingValue; use std::collections::HashMap; use std::sync::{PoisonError, RwLockReadGuard}; use thiserror::Error; use url::Url; #[derive(Debug, Error)] pub enum PlexApiError { #[error("Unable to perform a HTTP-request: {source}")] ReqwestError { #[from] source: reqwest::Error, }, #[error("Unable to deserialize XML: {source}")] XmlDeserialiseError { #[from] source: quick_xml::DeError, }, #[error("Unable to deserialize JSON: {source}")] JsonDeserealiseError { #[from] source: serde_json::Error, }, #[error("RwLock was poisoned")] LockReadPoison, #[error("Error while communicating with MyPlexApi: {errors:?}")] MyPlexErrorResponse { errors: Vec<PlexApiError> }, #[error("Error occurred while communicating to MyPlex API: #{code} - {message}")] MyPlexApiError { code: i32, message: String }, #[error("Unable to get the claim token: {0}")] FailedToGetClaimToken(String), #[error("Unable to parse request URL: {source}")] UrlParseError { #[from] source: url::ParseError, }, #[error("Failed to delete the object because delete_url is unknown for it")] DeleteUrlIsNotProvided, #[error("Requested webhook not found ({url})")] WebhookNotFound { url: String }, #[error("Received an unexpected response from API: {0}")] UnexpectedApiResponse(String), #[error("You've called update_settings(), but no settings were actually updated in provided container")] NoChangedSettingsFound, #[error("The device doesn't provide 'server' (but provides following: {provides:?})")] CurrentDeviceIsNotServer { provides: Vec<String> }, #[error("Can't connect to the device without any connection methods provided")] EmptyConnectionsList, #[error("Can't connect to the device, occurred errors: {errors:?}")] ConnectionFailed { errors: HashMap<Url, PlexApiError> }, #[error("Unknown setting requested (key={key}, known settings: {known}")] UnknownSettingRequested { key: String, known: String }, #[error("SettingValue::Bool was expected, but provided another: {provided:?}")] ExpectedSettingValueBool { provided: SettingValue }, #[error("SettingValue::Int was expected, but provided another: {provided:?}")] ExpectedSettingValueInt { provided: SettingValue }, #[error("SettingValue::Text was expected, but provided another: {provided:?}")] ExpectedSettingValueText { provided: SettingValue }, #[error("SettingValue::Double was expected, but provided another: {provided:?}")] ExpectedSettingValueDouble { provided: SettingValue }, } impl From<std::sync::PoisonError<std::sync::RwLockReadGuard<'_, reqwest::Client>>> for PlexApiError { fn from(_: PoisonError<RwLockReadGuard<'_, reqwest::Client>>) -> Self { PlexApiError::LockReadPoison } }