Skip to main content

edgehog_device_runtime/
error.rs

1// This file is part of Edgehog.
2//
3// Copyright 2022 - 2025 SECO Mind Srl
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9//    http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// SPDX-License-Identifier: Apache-2.0
18
19use astarte_device_sdk::event::FromEventError;
20use thiserror::Error;
21
22use crate::data::astarte_device_sdk_lib::DeviceSdkError;
23
24#[derive(Error, Debug)]
25pub enum DeviceManagerError {
26    #[error(transparent)]
27    Astarte(#[from] astarte_device_sdk::error::Error),
28
29    #[error(transparent)]
30    Procfs(#[from] procfs::ProcError),
31
32    #[error(transparent)]
33    Io(#[from] std::io::Error),
34
35    #[cfg(all(feature = "zbus", target_os = "linux"))]
36    #[error(transparent)]
37    Zbus(#[from] zbus::Error),
38
39    #[error("unrecoverable error ({0})")]
40    Fatal(String),
41
42    #[error(transparent)]
43    Reqwest(#[from] reqwest::Error),
44
45    #[error(transparent)]
46    SerdeJson(#[from] serde_json::Error),
47
48    #[cfg(all(feature = "zbus", target_os = "linux"))]
49    #[error(transparent)]
50    Ota(#[from] crate::ota::OtaError),
51
52    #[error("configuration file error")]
53    ConfigFile(#[from] toml::de::Error),
54
55    #[error("integer parse error")]
56    ParseInt(#[from] std::num::ParseIntError),
57
58    #[error("device SDK error")]
59    DeviceSdk(#[from] DeviceSdkError),
60
61    #[cfg(feature = "message-hub")]
62    #[error("message hub error")]
63    MessageHub(#[from] crate::data::astarte_message_hub_node::MessageHubError),
64
65    #[error("the connection was closed")]
66    Disconnected,
67
68    #[error("couldn't connect to the store")]
69    Store(#[from] astarte_device_sdk::store::sqlite::SqliteError),
70
71    #[error("couldn't convert device event")]
72    FromEvent(#[from] FromEventError),
73
74    #[cfg(feature = "containers")]
75    #[error("container operation failed")]
76    Containers(#[from] edgehog_containers::service::ServiceError),
77
78    #[cfg(feature = "containers")]
79    #[error("couldn't open database")]
80    Database(#[from] edgehog_store::db::HandleError),
81
82    #[cfg(feature = "forwarder")]
83    #[error("forwarder error")]
84    Forwarder(#[from] crate::forwarder::ForwarderError),
85}