daemonize_me/
errors.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum DaemonError {
5    #[error("This feature is unavailable, or not implemented for your target os")]
6    UnsupportedOnOS,
7    #[error("Unable to fork")]
8    Fork,
9    #[error("Failed to chdir")]
10    ChDir,
11    #[error("Failed to open dev null")]
12    OpenDevNull,
13    #[error("Failed to close the file pointer of a stdio stream")]
14    CloseFp,
15    #[error("Invalid or nonexistent user")]
16    InvalidUser,
17    #[error("Invalid or nonexistent group")]
18    InvalidGroup,
19    #[error("Either group or user was specified but not the other")]
20    InvalidUserGroupPair,
21    #[error("The specified cstr is invalid")]
22    InvalidCstr,
23    #[error("Failed to execute initgroups")]
24    InitGroups,
25    #[error("Failed to set uid")]
26    SetUid,
27    #[error("Failed to set gid")]
28    SetGid,
29    #[error("Failed to chown the pid file")]
30    ChownPid,
31    #[error("Failed to create the pid file")]
32    OpenPid,
33    #[error("Failed to write to the pid file")]
34    WritePid,
35    #[error("Failed to redirect the standard streams")]
36    RedirectStream,
37    #[error("Umask bits are invalid")]
38    InvalidUmaskBits,
39    #[error("Failed to set sid")]
40    SetSid,
41    #[error("Failed to get groups record")]
42    GetGrRecord,
43    #[error("Failed to get passwd record")]
44    GetPasswdRecord,
45    #[error("Failed to set proc name")]
46    SetProcName,
47    #[error("Failed to set proc name")]
48    InvalidProcName,
49}
50
51pub type Result<T> = std::result::Result<T, DaemonError>;