pueue_lib/
error.rs

1//! Pueue-lib errors.
2use std::path::PathBuf;
3
4#[cfg(any(feature = "network", feature = "network_blocking"))]
5use ciborium::Value;
6
7#[derive(thiserror::Error, Debug)]
8pub enum Error {
9    #[error("Error while building path: {}", .0)]
10    InvalidPath(String),
11
12    /// Any errors regarding the certificate setup.
13    #[error("Invalid or malformed certificate: {}", .0)]
14    CertificateFailure(String),
15
16    #[error("{}", .0)]
17    Connection(String),
18
19    #[error("Got an empty payload")]
20    EmptyPayload,
21
22    #[error("Couldn't deserialize message:\n{}", .0)]
23    MessageDeserialization(String),
24
25    #[cfg(any(feature = "network", feature = "network_blocking"))]
26    #[error("Got unexpected but valid message. Are you up-to-date?:\n{:#?}", .0)]
27    UnexpectedPayload(Value),
28
29    #[error("Couldn't serialize message:\n{}", .0)]
30    MessageSerialization(String),
31
32    #[error("Requested message size of {} with only {} being allowed.", .0, .1)]
33    MessageTooBig(usize, usize),
34
35    #[error("Error while reading configuration:\n{}", .0)]
36    ConfigDeserialization(String),
37
38    #[error("Some error occurred. {}", .0)]
39    Generic(String),
40
41    #[error("I/O error while {}:\n{}", .0, .1)]
42    IoError(String, std::io::Error),
43
44    #[error("Unexpected I/O error:\n{}", .0)]
45    RawIoError(#[from] std::io::Error),
46
47    #[error("I/O error at path {:?} while {}:\n{}", .0, .1, .2)]
48    IoPathError(PathBuf, &'static str, std::io::Error),
49
50    /// Thrown if one tries to create the unix socket, but it already exists.
51    /// Another daemon instance might be already running.
52    #[error(
53        "There seems to be an active pueue daemon.\n\
54            If you're sure there isn't, please remove the \
55            socket inside the pueue_directory manually."
56    )]
57    UnixSocketExists,
58}