ash_flare/supervisor/
error.rs1use std::fmt;
4
5#[derive(Debug)]
7pub enum SupervisorError {
8 NoChildren(String),
10 AllChildrenFailed(String),
12 ShuttingDown(String),
14 ChildAlreadyExists(String),
16 ChildNotFound(String),
18}
19
20impl fmt::Display for SupervisorError {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 match self {
23 SupervisorError::NoChildren(name) => {
24 write!(f, "supervisor '{}' has no children", name)
25 }
26 SupervisorError::AllChildrenFailed(name) => {
27 write!(
28 f,
29 "all children failed for supervisor '{}' - restart intensity limit exceeded",
30 name
31 )
32 }
33 SupervisorError::ShuttingDown(name) => {
34 write!(
35 f,
36 "supervisor '{}' is shutting down - operation not permitted",
37 name
38 )
39 }
40 SupervisorError::ChildAlreadyExists(id) => {
41 write!(
42 f,
43 "child with id '{}' already exists - use a unique identifier",
44 id
45 )
46 }
47 SupervisorError::ChildNotFound(id) => {
48 write!(
49 f,
50 "child with id '{}' not found - it may have already terminated",
51 id
52 )
53 }
54 }
55 }
56}
57
58impl std::error::Error for SupervisorError {}