use crate::response::Error as ResponseError;
use chrono::ParseError as ChronoParseError;
use serde_json::Error as SerdeJsonError;
#[cfg(feature = "upnp-description")]
use serde_xml_rs::Error as SerdeXmlError;
use std::result::Result as StdResult;
use std::{io::Error as IoError, net::AddrParseError};
use thiserror::Error as ThisError;
use ureq::Error as UreqError;
pub type Result<T> = StdResult<T, Error>;
#[derive(Debug, ThisError)]
pub enum Error {
#[error("Failed to get username")]
GetUsername,
#[error("Failed to get identifier of created resource")]
GetCreatedId,
#[error("Failed to parse date")]
ParseDate(#[from] ChronoParseError),
#[error("Failed to parse http response")]
ParseHttpResponse(#[from] IoError),
#[error("Failed to parse ip address")]
ParseIpAddr(#[from] AddrParseError),
#[error("Failed to parse json content")]
ParseJson(#[from] SerdeJsonError),
#[error("Failed to send HTTP request")]
Request(#[from] Box<UreqError>),
#[cfg(feature = "upnp-description")]
#[error("Failed to parse description")]
ParseDescription(#[from] SerdeXmlError),
#[error("Error returned from Philips Hue API")]
Response(#[from] ResponseError),
}
impl From<UreqError> for Error {
fn from(ureq_error: UreqError) -> Self {
Self::Request(Box::new(ureq_error))
}
}