automation_rs/google-home/src/errors.rs
Dreaded_X 3645b53f7c
All checks were successful
continuous-integration/drone/push Build is passing
Applied rust fmt
2023-04-10 01:33:39 +02:00

41 lines
995 B
Rust

use serde::Serialize;
use thiserror::Error;
#[derive(Debug, Hash, PartialEq, Eq, Copy, Clone, Serialize, Error)]
#[serde(rename_all = "camelCase")]
pub enum DeviceError {
#[error("deviceNotFound")]
DeviceNotFound,
#[error("deviceOffline")]
DeviceOffline,
#[error("actionNotAvailable")]
ActionNotAvailable,
#[error("transientError")]
TransientError,
}
#[derive(Debug, Hash, PartialEq, Eq, Copy, Clone, Serialize, Error)]
#[serde(rename_all = "camelCase")]
pub enum DeviceException {}
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy, Serialize, Error)]
#[serde(untagged)]
pub enum ErrorCode {
#[error("{0}")]
DeviceError(DeviceError),
#[error("{0}")]
DeviceException(DeviceException),
}
impl From<DeviceError> for ErrorCode {
fn from(value: DeviceError) -> Self {
Self::DeviceError(value)
}
}
impl From<DeviceException> for ErrorCode {
fn from(value: DeviceException) -> Self {
Self::DeviceException(value)
}
}