ant_service_management/
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 - this is a 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    AddrParseError(#[from] std::net::AddrParseError),
20    #[error("The endpoint for the daemon has not been set")]
21    DaemonEndpointNotSet,
22    #[error(transparent)]
23    Io(#[from] std::io::Error),
24    #[error(transparent)]
25    Json(#[from] serde_json::Error),
26    #[error(transparent)]
27    MultiAddrParseError(#[from] libp2p::multiaddr::Error),
28    #[error("The registry does not contain a service named '{0}'")]
29    NodeNotFound(String),
30    #[error(transparent)]
31    ParseIntError(#[from] std::num::ParseIntError),
32    #[error(transparent)]
33    PeerIdParseError(#[from] libp2p_identity::ParseError),
34    #[error("Could not connect to RPC endpoint '{0}'")]
35    RpcConnectionError(String),
36    #[error("Could not obtain node info through RPC: {0}")]
37    RpcNodeInfoError(String),
38    #[error("Could not obtain network info through RPC: {0}")]
39    RpcNetworkInfoError(String),
40    #[error("Could not restart node through RPC: {0}")]
41    RpcNodeRestartError(String),
42    #[error("Could not stop node through RPC: {0}")]
43    RpcNodeStopError(String),
44    #[error("Could not update node through RPC: {0}")]
45    RpcNodeUpdateError(String),
46    #[error("Could not obtain record addresses through RPC: {0}")]
47    RpcRecordAddressError(String),
48    #[error("Could not find process at '{0}'")]
49    ServiceProcessNotFound(String),
50    #[error("The service '{0}' does not exists and cannot be removed.")]
51    ServiceDoesNotExists(String),
52    #[error("The user may have removed the '{0}' service outwith the node manager")]
53    ServiceRemovedManually(String),
54    #[error("Failed to create service user account")]
55    ServiceUserAccountCreationFailed,
56    #[error("Could not obtain user's data directory")]
57    UserDataDirectoryNotObtainable,
58    #[error(transparent)]
59    Utf8Error(#[from] std::str::Utf8Error),
60}