#[derive(thiserror::Error, Debug)]
#[allow(missing_docs)]
pub enum Error
{
#[error("UTF8 Error: '{0}'")]
Utf8Error(#[from] std::str::Utf8Error),
#[error("MQTT Connection Error: '{0}'")]
#[cfg(feature = "mqtt")]
MQTTConnectionError(#[from] rumqttc::v5::ConnectionError),
#[error("Capability '{0}' is unknown.")]
UnknownCapability(&'static str),
#[error("Capability '{0}' already defined.")]
DuplicateCapability(&'static str),
#[error("An error occured during transport: '{0}'.")]
TransportError(String),
#[error("Invalid task type: {0}.")]
InvalidTaskType(String),
#[error("Unknown task type: {0}.")]
UnknownTaskType(String),
#[error("State '{0}' is unknown.")]
UnknownState(&'static str),
#[error("State '{0}' already defined.")]
DuplicateState(&'static str),
#[error("The execution failed: {0}.")]
ExecutionFailed(String),
#[error("The task '{0}' cannot be executed.")]
CannotExecute(String),
#[error("No executor.")]
NoExecutor(),
#[error("Invalid collection: {0}.")]
InvalidCollection(String),
#[error("Unknown value in collection {0} with key {1}.")]
UnknownValue(String, String),
#[error("Serialization error: {0}")]
SerializationError(String),
#[error("Deserialization error: {0}")]
DeserializationError(String),
#[error("Mutex error: {0}")]
MutexError(String),
#[error("Runtime error: {0}")]
Runtime(String),
#[error("Invalid UUID: {0} with error {1}")]
InvalidUuid(String, String),
#[error("Unimplemented: {0}.")]
Unimplemented(&'static str),
}
impl<'a, T> From<std::sync::PoisonError<std::sync::MutexGuard<'a, T>>> for Error
{
fn from(value: std::sync::PoisonError<std::sync::MutexGuard<'a, T>>) -> Self
{
Error::MutexError(value.to_string())
}
}
impl From<serde_json::Error> for Error
{
fn from(value: serde_json::Error) -> Self
{
Error::SerializationError(value.to_string())
}
}
impl From<yaaral::NoError> for Error
{
fn from(value: yaaral::NoError) -> Self
{
Error::Unimplemented("yaaral::NoError should never trigger.")
}
}