appletheia_application/command/
command_dispatch_error.rs1use std::error::Error;
2
3use thiserror::Error;
4
5use crate::command::CommandFailureReport;
6use crate::command::CommandHasherError;
7use crate::idempotency::IdempotencyError;
8use crate::request_context::MessageId;
9use crate::unit_of_work::UnitOfWorkError;
10use crate::unit_of_work::UnitOfWorkFactoryError;
11
12#[derive(Debug, Error)]
13pub enum CommandDispatchError<HE>
14where
15 HE: Error + Send + Sync + 'static,
16{
17 #[error("unit of work factory error: {0}")]
18 UnitOfWorkFactory(#[from] UnitOfWorkFactoryError),
19
20 #[error("unit of work error: {0}")]
21 UnitOfWork(#[from] UnitOfWorkError),
22
23 #[error("idempotency error: {0}")]
24 Idempotency(#[from] IdempotencyError),
25
26 #[error("command handler error: {0}")]
27 Handler(#[source] HE),
28
29 #[error("command is still in progress: {message_id}")]
30 InProgress { message_id: MessageId },
31
32 #[error("previous command failed: {0}")]
33 PreviousFailure(CommandFailureReport),
34
35 #[error("command hasher error: {0}")]
36 Hasher(#[from] CommandHasherError),
37
38 #[error("json error: {0}")]
39 Json(#[from] serde_json::Error),
40}