use thiserror::Error;
use ironflow_core::error::OperationError;
use ironflow_engine::error::EngineError;
use ironflow_store::error::StoreError;
#[derive(Debug, Error)]
pub enum WorkerError {
#[error("operation error: {0}")]
Operation(#[from] OperationError),
#[error("engine error: {0}")]
Engine(#[from] EngineError),
#[error("store error: {0}")]
Store(#[from] StoreError),
#[error("shutdown error: {0}")]
Shutdown(String),
#[error("internal error: {0}")]
Internal(String),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn shutdown_error_display() {
let err = WorkerError::Shutdown("worker stopped".to_string());
let msg = err.to_string();
assert!(msg.contains("shutdown error"));
assert!(msg.contains("worker stopped"));
}
#[test]
fn internal_error_display() {
let err = WorkerError::Internal("something went wrong".to_string());
let msg = err.to_string();
assert!(msg.contains("internal error"));
assert!(msg.contains("something went wrong"));
}
#[test]
fn shutdown_error_debug() {
let err = WorkerError::Shutdown("test".to_string());
let debug_str = format!("{:?}", err);
assert!(debug_str.contains("Shutdown"));
}
#[test]
fn internal_error_debug() {
let err = WorkerError::Internal("test".to_string());
let debug_str = format!("{:?}", err);
assert!(debug_str.contains("Internal"));
}
}