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