1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! # Errors module
//!
//! This module defines error types for the actor system using `thiserror`.
use crate::ActorPath;
use thiserror::Error;
/// Error type for the actor system.
#[derive(Clone, Debug, Error, PartialEq, Eq)]
pub enum Error {
// ===== Actor Lifecycle Errors =====
/// Actor already exists at the specified path.
///
/// This error indicates an attempt to create an actor at a path
/// that is already occupied.
#[error("actor '{path}' already exists")]
Exists {
/// The path where the actor already exists.
path: ActorPath,
},
/// Actor not found at the specified path.
///
/// This error indicates that no actor exists at the requested path.
#[error("actor '{path}' not found")]
NotFound {
/// The path where the actor was expected but not found.
path: ActorPath,
},
/// Actor creation was attempted while the system was stopping or already stopped.
#[error("actor system is stopping or stopped")]
SystemStopped,
// ===== Message Passing Errors =====
/// Failed to send a message to an actor.
///
/// This error occurs when a message cannot be delivered to an actor's mailbox.
#[error("failed to send message: {reason}")]
Send {
/// The reason why message sending failed.
reason: String,
},
/// Actor returned an unexpected response type.
///
/// This error occurs when an actor's response doesn't match the expected type.
#[error(
"actor '{path}' returned unexpected response, expected: {expected}"
)]
UnexpectedResponse {
/// The path of the actor that sent the unexpected response.
path: ActorPath,
/// Description of the expected response type.
expected: String,
},
/// Failed to send an event to the event bus.
///
/// This error occurs when an event cannot be published to the event bus.
#[error("failed to send event to event bus: {reason}")]
SendEvent {
/// The reason why event sending failed.
reason: String,
},
/// A store operation failed.
///
/// This error covers various store operations that don't fit into
/// more specific error categories.
#[error("store operation '{operation}' failed: {reason}")]
StoreOperation {
/// The operation that was being performed.
operation: String,
/// The reason why the operation failed.
reason: String,
},
// ===== Helper Errors =====
/// Failed to access a helper.
///
/// This error occurs when a required helper cannot be accessed.
#[error("failed to access helper '{name}': {reason}")]
Helper {
/// The name of the helper that could not be accessed.
name: String,
/// The reason why helper access failed.
reason: String,
},
/// Maximum number of retry attempts reached.
///
/// This error occurs when an operation has been retried the maximum
/// allowed number of times without success.
#[error("maximum retry attempts reached")]
Retry,
// ===== Shutdown Errors =====
/// The actor was stopped before processing this message.
///
/// This error occurs when an actor is shutting down and discards
/// non-critical messages from its mailbox.
#[error("actor stopped before processing message")]
ActorStopped,
/// The ask request timed out before the actor responded.
#[error("ask timed out after {ms}ms")]
Timeout {
/// Duration waited in milliseconds.
ms: u128,
},
// ===== Functional Errors =====
/// A recoverable functional error.
///
/// This error indicates a problem that doesn't compromise the system's
/// overall operation and may be recoverable.
#[error("{description}")]
Functional {
/// Description of the functional error.
description: String,
},
/// A critical functional error.
///
/// This error indicates a problem that compromises the system's operation
/// and requires intervention.
#[error("{description}")]
FunctionalCritical {
/// Description of the critical error.
description: String,
},
}