ant_node_manager/
error.rs

1// Copyright 2024 MaidSafe.net limited.
2//
3// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
4// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
5// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6// KIND, either express or implied. Please review the Licences for the specific language governing
7// permissions and limitations relating to use of the SAFE Network Software.
8
9// Allow enum variant names that end with Error - common pattern with thiserror
10#![allow(clippy::enum_variant_names)]
11
12use thiserror::Error;
13
14pub type Result<T, E = Error> = std::result::Result<T, E>;
15
16#[derive(Debug, Error)]
17pub enum Error {
18    #[error(transparent)]
19    Json(#[from] serde_json::Error),
20    #[error(transparent)]
21    Io(#[from] std::io::Error),
22    #[error("The PID of the process was not found after starting it.")]
23    PidNotFoundAfterStarting,
24    #[error("The PID of the process was not set.")]
25    PidNotSet,
26    #[error(transparent)]
27    SemverError(#[from] semver::Error),
28    #[error("Unable to remove a running service {0:?}, stop this service first before removing")]
29    ServiceAlreadyRunning(Vec<String>),
30    #[error("The service(s) is not running: {0:?}")]
31    ServiceNotRunning(Vec<String>),
32    #[error(transparent)]
33    ServiceManagementError(#[from] ant_service_management::Error),
34    #[error("The service status is not as expected. Expected: {expected:?}")]
35    ServiceStatusMismatch {
36        expected: ant_service_management::ServiceStatus,
37    },
38}