torrust_tracker_deployer_lib/adapters/network/
error.rs1use thiserror::Error;
4
5use crate::shared::command::CommandError;
6
7#[derive(Debug, Error)]
9pub enum NetworkError {
10 #[error(
12 "Failed to execute netstat command
13Tip: Verify netstat is installed: 'which netstat' or 'apt-get install net-tools'"
14 )]
15 NetstatFailed(#[source] CommandError),
16
17 #[error(
19 "Failed to execute ss command
20Tip: Verify ss is installed: 'which ss' or 'apt-get install iproute2'"
21 )]
22 SsFailed(#[source] CommandError),
23}
24
25impl NetworkError {
26 #[must_use]
46 pub fn help(&self) -> &'static str {
47 match self {
48 Self::NetstatFailed(_) => {
49 "Netstat Command Failed - Detailed Troubleshooting:
50
511. Check if netstat is installed:
52 which netstat
53
542. Install netstat if missing:
55 Debian/Ubuntu: sudo apt-get install net-tools
56 RHEL/CentOS: sudo yum install net-tools
57 Alpine: sudo apk add net-tools
58 macOS: netstat is pre-installed
59
603. Verify permissions:
61 - Some netstat options require root/sudo for full process information
62 - Try running the command manually: netstat -tlnp
63
644. Alternative: Use ss command instead (modern Linux):
65 - ss is the modern replacement for netstat
66 - Usually available via iproute2 package
67
68For more information, see: man netstat"
69 }
70
71 Self::SsFailed(_) => {
72 "SS Command Failed - Detailed Troubleshooting:
73
741. Check if ss is installed:
75 which ss
76
772. Install ss if missing:
78 Debian/Ubuntu: sudo apt-get install iproute2
79 RHEL/CentOS: sudo yum install iproute2
80 Alpine: sudo apk add iproute2
81 macOS: ss is not available, use netstat instead
82
833. Verify permissions:
84 - Some ss options require root/sudo for full process information
85 - Try running the command manually: ss -tlnp
86
874. Alternative: Use netstat command instead:
88 - netstat is the traditional tool for network statistics
89 - Usually available via net-tools package
90
91For more information, see: man ss"
92 }
93 }
94 }
95}