Skip to main content

liminal_server/console/
error.rs

1//! What a console stream operation can fail with.
2
3use crate::ServerError;
4use crate::tap::TapError;
5
6/// A console stream operation's failure.
7#[derive(Debug, thiserror::Error)]
8pub enum ConsoleError {
9    /// A tap or feed lock was poisoned.
10    #[error(transparent)]
11    Tap(#[from] TapError),
12    /// Building the topology or publishing a record failed.
13    #[error("console {subject}: {source}")]
14    Server {
15        /// The subject being built or published.
16        subject: String,
17        /// The server's error.
18        #[source]
19        source: ServerError,
20    },
21    /// A record could not be serialised.
22    #[error("console {record} record could not be encoded: {source}")]
23    Encode {
24        /// Which record (`topology` or `tap.batch`).
25        record: &'static str,
26        /// The serialiser's error.
27        #[source]
28        source: serde_json::Error,
29    },
30    /// The wall clock could not give the console a time.
31    #[error("console clock: {reason}")]
32    Clock {
33        /// What was wrong with the reading.
34        reason: String,
35    },
36    /// A new tap would pass the live-tap limit (`CONSOLE_TAP_LIMIT_REFUSED`).
37    #[error("console tap {subject} refused: {limit} taps are live")]
38    TapLimit {
39        /// The `console.tap.<target>` subject.
40        subject: String,
41        /// The limit.
42        limit: usize,
43    },
44    /// The device name is empty, so `liminal.<device>` would be meaningless.
45    #[error("console device name is empty")]
46    EmptyDevice,
47}