Skip to content

Commit 7f05343

Browse files
committed
refactor: use target_os specific error enum definition
Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
1 parent 210997a commit 7f05343

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
use std::path::PathBuf;
22

33
pub async fn start_watchdog(_config_dir: PathBuf) -> Result<(), anyhow::Error> {
4-
Err(anyhow::Error::from(
5-
crate::error::WatchdogError::WatchdogNotAvailable,
6-
))
4+
Err(anyhow::Error::from(WatchdogError::WatchdogNotAvailable))
5+
}
6+
7+
#[derive(Debug, thiserror::Error)]
8+
pub enum WatchdogError {
9+
#[error("The watchdog is not available on this platform")]
10+
WatchdogNotAvailable,
711
}

crates/core/tedge_watchdog/src/error.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
use time::error::Parse;
2-
31
use mqtt_channel::MqttError;
4-
52
use tedge_config::CertificateError;
63
use tedge_config::ConfigSettingError;
74
use tedge_config::TEdgeConfigError;
5+
use time::error::Parse;
86

97
#[derive(Debug, thiserror::Error)]
108
pub enum WatchdogError {
11-
#[cfg(not(target_os = "linux"))]
12-
#[error("The watchdog is not available on this platform")]
13-
WatchdogNotAvailable,
14-
159
#[error("MQTT receiver closed")]
1610
ChannelClosed,
1711

crates/core/tedge_watchdog/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use std::path::PathBuf;
22
use tedge_config::system_services::*;
33
use tedge_config::DEFAULT_TEDGE_CONFIG_PATH;
44

5-
mod error;
6-
75
// on linux, we use systemd
86
#[cfg(target_os = "linux")]
97
mod systemd_watchdog;
108
#[cfg(target_os = "linux")]
119
use systemd_watchdog as watchdog;
10+
#[cfg(target_os = "linux")]
11+
mod error;
1212

1313
// on non-linux, we do nothing for now
1414
#[cfg(not(target_os = "linux"))]

0 commit comments

Comments
 (0)