summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-03-06 13:45:58 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2018-03-08 07:16:56 -0300
commit48e67360238e284ae6118e2f79e2bc4d53b69db3 (patch)
treef6e0500ca6368c70b1ad9d373937415557d024f8
parent806ecbc28b25652637f5b6e7a70102239ca27632 (diff)
downloadmullvadvpn-48e67360238e284ae6118e2f79e2bc4d53b69db3.tar.xz
mullvadvpn-48e67360238e284ae6118e2f79e2bc4d53b69db3.zip
Remove unnecessary error types
Executable without parent directory should never happen. In either case, the current working directory is used as a fallback and the error is logged. This is the same procedure used for the resources directory.
-rw-r--r--talpid-core/src/tunnel/mod.rs31
1 files changed, 15 insertions, 16 deletions
diff --git a/talpid-core/src/tunnel/mod.rs b/talpid-core/src/tunnel/mod.rs
index a623630106..086275f981 100644
--- a/talpid-core/src/tunnel/mod.rs
+++ b/talpid-core/src/tunnel/mod.rs
@@ -26,14 +26,6 @@ mod errors {
TunnelMonitoringError {
description("Error while setting up or processing events from the VPN tunnel")
}
- /// Failed to get the current executable path.
- ExecutablePathInaccessible {
- description("Error while reading current executable path")
- }
- /// Obtained executable path doesn't have a parent directory.
- ExecutableHasNoParentDir {
- description("Executable path has no directories")
- }
/// The OpenVPN plugin was not found.
PluginNotFound {
description("No OpenVPN plugin found")
@@ -199,7 +191,7 @@ impl TunnelMonitor {
fn get_plugin_path() -> Result<PathBuf> {
let library = Self::get_library_name().chain_err(|| ErrorKind::PluginNotFound)?;
- let mut path = Self::get_executable_dir().chain_err(|| ErrorKind::PluginNotFound)?;
+ let mut path = Self::get_executable_dir();
path.push(library);
@@ -211,13 +203,20 @@ impl TunnelMonitor {
}
}
- fn get_executable_dir() -> Result<PathBuf> {
- let exe_path = env::current_exe().chain_err(|| ErrorKind::ExecutablePathInaccessible)?;
-
- exe_path
- .parent()
- .map(Path::to_path_buf)
- .ok_or(ErrorKind::ExecutableHasNoParentDir.into())
+ fn get_executable_dir() -> PathBuf {
+ match env::current_exe() {
+ Ok(mut path) => {
+ path.pop();
+ path
+ }
+ Err(e) => {
+ error!(
+ "Failed finding the install directory. Using working directory: {}",
+ e
+ );
+ PathBuf::from(".")
+ }
+ }
}
fn get_library_name() -> Result<&'static str> {