actor_sample/product_actor/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
10#[allow(dead_code)]
11pub enum ProductError {
12 #[error("Product not found: {0}")]
14 NotFound(String),
15
16 #[error("Insufficient stock: requested {requested}, available {available}")]
18 InsufficientStock { requested: u32, available: u32 },
19
20 #[error("Invalid quantity: {0}")]
22 InvalidQuantity(u32),
23
24 #[error("Invalid price: {0}")]
26 InvalidPrice(f64),
27
28 #[error("Product database error: {0}")]
30 DatabaseError(String),
31
32 #[error("Actor communication error: {0}")]
34 ActorCommunicationError(String),
35}
36
37impl From<String> for ProductError {
38 fn from(msg: String) -> Self {
39 ProductError::ActorCommunicationError(msg)
40 }
41}