forked from lambdaclass/spawned
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
38 lines (34 loc) · 969 Bytes
/
error.rs
File metadata and controls
38 lines (34 loc) · 969 Bytes
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
#[derive(Debug, thiserror::Error)]
pub enum ActorError {
#[error("Callback Error")]
Callback,
#[error("Initialization error")]
Initialization,
#[error("Server error")]
Server,
#[error("Unsupported Request on this Actor")]
RequestUnused,
#[error("Unsupported Message on this Actor")]
MessageUnused,
#[error("Request to Actor timed out")]
RequestTimeout,
}
impl<T> From<spawned_rt::threads::mpsc::SendError<T>> for ActorError {
fn from(_value: spawned_rt::threads::mpsc::SendError<T>) -> Self {
Self::Server
}
}
impl<T> From<spawned_rt::tasks::mpsc::SendError<T>> for ActorError {
fn from(_value: spawned_rt::tasks::mpsc::SendError<T>) -> Self {
Self::Server
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_error_into_std_error() {
let error: &dyn std::error::Error = &ActorError::Callback;
assert_eq!(error.to_string(), "Callback Error");
}
}