Skip to content

Commit b2239c5

Browse files
author
Maciej Wójcik
committed
remove unnecessary error from enum
1 parent 4cb4918 commit b2239c5

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

src/error.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ pub enum WireguardInterfaceError {
3434
#[error("DNS error: {0}")]
3535
DnsError(String),
3636
#[cfg(target_os = "windows")]
37-
#[error("Service installation failed: `{message}`")]
38-
ServiceInstallationFailed {
39-
err: std::io::Error,
40-
message: String,
41-
},
37+
#[error("Service installation failed: `{0}`")]
38+
ServiceInstallationFailed(String),
4239
#[cfg(target_os = "windows")]
4340
#[error("Tunnel service removal failed: `{0}`")]
4441
ServiceRemovalFailed(String),

src/wgapi_windows.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
187187
.output()
188188
.map_err(|err| {
189189
error!("Failed to create interface. Error: {err}");
190-
let message = err.to_string();
191-
WireguardInterfaceError::ServiceInstallationFailed { err, message }
190+
WireguardInterfaceError::ServiceInstallationFailed(err.to_string())
192191
})?;
193192

194193
debug!("Done installing the new service. Service installation output: {service_installation_output:?}",);
@@ -198,10 +197,7 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
198197
"Failed to install WireGuard tunnel as a Windows service: {:?}",
199198
service_installation_output.stdout
200199
);
201-
return Err(WireguardInterfaceError::ServiceInstallationFailed {
202-
err: io::Error::new(io::ErrorKind::Other, "Cannot create service"),
203-
message,
204-
});
200+
return Err(WireguardInterfaceError::ServiceInstallationFailed(message));
205201
}
206202

207203
debug!(
@@ -215,8 +211,7 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
215211
.output()
216212
.map_err(|err| {
217213
error!("Failed to configure tunnel service. Error: {err}");
218-
let message = err.to_string();
219-
WireguardInterfaceError::ServiceInstallationFailed { err, message }
214+
WireguardInterfaceError::ServiceInstallationFailed(err.to_string())
220215
})?;
221216

222217
debug!("Done disabling automatic restart for the new service. Service update output: {service_update_output:?}",);
@@ -225,10 +220,7 @@ impl WireguardInterfaceApi for WGApi<Kernel> {
225220
"Failed to configure WireGuard tunnel service: {:?}",
226221
service_update_output.stdout
227222
);
228-
return Err(WireguardInterfaceError::ServiceInstallationFailed {
229-
err: io::Error::new(io::ErrorKind::Other, "Cannot configure service"),
230-
message,
231-
});
223+
return Err(WireguardInterfaceError::ServiceInstallationFailed(message));
232224
}
233225

234226
// TODO: set maximum transfer unit (MTU)

0 commit comments

Comments
 (0)