Mercurial > crates > systemd-socket
comparison src/error.rs @ 16:bc76507dd878
Fixed conditional compilation based on OS
A mistake was causing systemd to never enable and the tests were too
clever to detect that. Not sure what to do with it.
author | Martin Habovstiak <martin.habovstiak@gmail.com> |
---|---|
date | Tue, 22 Dec 2020 13:58:47 +0100 |
parents | f740dadd2948 |
children | f6334887e3c8 |
comparison
equal
deleted
inserted
replaced
15:08b37039504b | 16:bc76507dd878 |
---|---|
17 | 17 |
18 #[derive(Debug, Error)] | 18 #[derive(Debug, Error)] |
19 pub(crate) enum ParseErrorInner { | 19 pub(crate) enum ParseErrorInner { |
20 #[error("failed to parse socket address")] | 20 #[error("failed to parse socket address")] |
21 ResolvAddr(#[from] crate::resolv_addr::ResolvAddrError), | 21 ResolvAddr(#[from] crate::resolv_addr::ResolvAddrError), |
22 #[cfg(all(linux, feature = "enable_systemd"))] | 22 #[cfg(all(target_os = "linux", feature = "enable_systemd"))] |
23 #[error("invalid character '{c}' in systemd socket name {string} at position {pos}")] | 23 #[error("invalid character '{c}' in systemd socket name {string} at position {pos}")] |
24 InvalidCharacter { string: String, c: char, pos: usize, }, | 24 InvalidCharacter { string: String, c: char, pos: usize, }, |
25 #[cfg(all(linux, feature = "enable_systemd"))] | 25 #[cfg(all(target_os = "linux", feature = "enable_systemd"))] |
26 #[error("systemd socket name {string} is {len} characters long which is more than the limit 255")] | 26 #[error("systemd socket name {string} is {len} characters long which is more than the limit 255")] |
27 LongSocketName { string: String, len: usize, }, | 27 LongSocketName { string: String, len: usize, }, |
28 #[cfg(not(all(linux, feature = "enable_systemd")))] | 28 #[cfg(not(all(target_os = "linux", feature = "enable_systemd")))] |
29 #[cfg_attr(not(linux), error("can't parse {0} because systemd is not supported on this operating system"))] | 29 #[cfg_attr(not(target_os = "linux"), error("can't parse {0} because systemd is not supported on this operating system"))] |
30 #[cfg_attr(linux, error("can't parse {0} because systemd support was disabled during build"))] | 30 #[cfg_attr(target_os = "linux", error("can't parse {0} because systemd support was disabled during build"))] |
31 SystemdUnsupported(String), | 31 SystemdUnsupported(String), |
32 } | 32 } |
33 | 33 |
34 /// Error that can occur during parsing of `SocketAddr` from a `OsStr`/`OsString` | 34 /// Error that can occur during parsing of `SocketAddr` from a `OsStr`/`OsString` |
35 /// | 35 /// |
64 pub(crate) enum BindErrorInner { | 64 pub(crate) enum BindErrorInner { |
65 #[error("failed to bind {addr}")] | 65 #[error("failed to bind {addr}")] |
66 BindFailed { addr: std::net::SocketAddr, #[source] error: io::Error, }, | 66 BindFailed { addr: std::net::SocketAddr, #[source] error: io::Error, }, |
67 #[error("failed to bind {addr}")] | 67 #[error("failed to bind {addr}")] |
68 BindOrResolvFailed { addr: crate::resolv_addr::ResolvAddr, #[source] error: io::Error, }, | 68 BindOrResolvFailed { addr: crate::resolv_addr::ResolvAddr, #[source] error: io::Error, }, |
69 #[cfg(all(linux, feature = "enable_systemd"))] | 69 #[cfg(all(target_os = "linux", feature = "enable_systemd"))] |
70 #[error("failed to receive descriptors with names")] | 70 #[error("failed to receive descriptors with names")] |
71 ReceiveDescriptors(#[source] crate::systemd_sockets::Error), | 71 ReceiveDescriptors(#[source] crate::systemd_sockets::Error), |
72 #[error("missing systemd socket {0} - a typo or an attempt to bind twice")] | 72 #[error("missing systemd socket {0} - a typo or an attempt to bind twice")] |
73 #[cfg(all(linux, feature = "enable_systemd"))] | 73 #[cfg(all(target_os = "linux", feature = "enable_systemd"))] |
74 MissingDescriptor(String), | 74 MissingDescriptor(String), |
75 #[error("the systemd socket {0} is not an internet socket")] | 75 #[error("the systemd socket {0} is not an internet socket")] |
76 #[cfg(all(linux, feature = "enable_systemd"))] | 76 #[cfg(all(target_os = "linux", feature = "enable_systemd"))] |
77 NotInetSocket(String), | 77 NotInetSocket(String), |
78 } | 78 } |
79 | 79 |
80 /// Error that can happen when binding Tokio socket. | 80 /// Error that can happen when binding Tokio socket. |
81 /// | 81 /// |