Skip to main content

tightbeam/colony/cluster/
error.rs

1//! Cluster-specific error types
2
3use crate::transport::error::TransportError;
4use crate::{Errorizable, TightBeamError};
5
6/// Errors specific to clusters
7///
8/// Failure modes are distinct variants (not string payloads) so callers
9/// can branch on them, and wrapper variants preserve their cause chain
10/// through [`core::error::Error::source`].
11#[derive(Errorizable, Debug)]
12pub enum ClusterError {
13	/// Lock poisoned
14	#[error("Lock poisoned")]
15	LockPoisoned,
16
17	/// Unknown servlet type
18	#[error("Unknown servlet type: {:#?}")]
19	UnknownServletType(Vec<u8>),
20
21	/// No hives available for servlet type
22	#[error("No hives available for servlet type: {:#?}")]
23	NoHivesAvailable(Vec<u8>),
24
25	/// Connection to the selected hive/servlet could not be established
26	#[error("Connect failed")]
27	ConnectFailed,
28
29	/// Peer accepted the request but returned no response frame
30	#[error("No response")]
31	NoResponse,
32
33	/// Transport-level failure while communicating with a hive/servlet
34	#[error("Transport error: {0}")]
35	#[from]
36	#[source]
37	Transport(TransportError),
38
39	/// Frame encode/decode/build/sign failure
40	#[error("Frame error: {0}")]
41	#[from]
42	#[source]
43	Frame(TightBeamError),
44
45	/// Response decoded but did not carry the expected field
46	#[error("Malformed response")]
47	MalformedResponse,
48
49	/// Registration failed
50	#[error("Registration failed")]
51	RegistrationFailed,
52
53	/// Invalid servlet address format
54	#[error("Invalid address: {:#?}")]
55	InvalidAddress(Vec<u8>),
56
57	/// Servlet address update referenced a route owned by a different hive
58	#[error("Servlet not owned by hive")]
59	ServletNotOwned,
60
61	/// Re-registration presented a signer that does not match the bound hive signer
62	#[error("Signer does not match hive binding")]
63	SignerMismatch,
64}
65
66impl<T> From<std::sync::PoisonError<T>> for ClusterError {
67	fn from(_: std::sync::PoisonError<T>) -> Self {
68		ClusterError::LockPoisoned
69	}
70}