Skip to content

Commit

Permalink
šŸ› use panic() instead of process::exit() to terminate only the pluginā€¦
Browse files Browse the repository at this point in the history
ā€¦ process
  • Loading branch information
friedow committed Oct 27, 2023
1 parent 77b8209 commit fbc1da1
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This project is currently in a very early state and tailored to my needs and dai
- [ ] unit converter (https://github.com/printfn/fend)
- [x] display resource monitor (cpu, gpu, ram, disks)
- [ ] split those into seperate files
- [ ] color background of entries based on the usage percentage
- [x] display battery state
- [x] display date and time
- [ ] display weather
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/applications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Plugin {
target: self.plugin.id.as_str(),
"{:?}", error
);
std::process::exit(1);
panic!();
}

let search_result = self.search(&String::from(""));
Expand Down
4 changes: 2 additions & 2 deletions client/src/plugin/brave/bookmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Plugin {
"{:?}", error
);
// TODO: process exit terminates the parent process as well! This is unwanted
std::process::exit(1);
panic!();
}

return Plugin {
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Plugin {
target: self.plugin.id.as_str(),
"{:?}", error,
);
std::process::exit(1);
panic!();
}

loop {
Expand Down
4 changes: 2 additions & 2 deletions client/src/plugin/brave/progressive_web_apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Plugin {
target: "brave-progressive-web-apps",
"{:?}", error
);
std::process::exit(1);
panic!();
}

return Plugin {
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Plugin {
target: self.plugin.id.as_str(),
"{:?}", error,
);
std::process::exit(1);
panic!();
}

loop {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Plugin {
target: self.plugin.id.as_str(),
"{:?}", error
);
std::process::exit(1);
panic!();
}

loop {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/git_repositories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Plugin {
target: self.plugin.id.as_str(),
"{:?}", error,
);
std::process::exit(1);
panic!();
}

loop {
Expand Down
2 changes: 1 addition & 1 deletion client/src/plugin/resource_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Plugin {
target: "resource-monitor",
"{:?}", error,
);
std::process::exit(1);
panic!();
}

let update_entries_result = self.update_entries();
Expand Down
6 changes: 3 additions & 3 deletions client/src/plugin/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where
error = log::as_error!(error);
"Could not read HOME environment variable",
);
std::process::exit(1);
panic!();
}
let home_directory = home_directory_result.unwrap();

Expand All @@ -53,7 +53,7 @@ where
error = log::as_error!(error);
"Error while opening index file",
);
std::process::exit(1);
panic!();
}
let index_file = index_file_result.unwrap();

Expand All @@ -64,7 +64,7 @@ where
error = log::as_error!(error);
"Error while reading index file",
);
std::process::exit(1);
panic!();
}
let git_repository_paths = git_repository_paths_result.unwrap();
git_repository_paths
Expand Down
6 changes: 3 additions & 3 deletions client/src/plugin/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Plugin {
target: "windows",
"{:?}", error,
);
std::process::exit(1);
panic!();
}
let mut sway = connection_result.unwrap();

Expand All @@ -41,7 +41,7 @@ impl Plugin {
target: "windows",
"{:?}", error,
);
std::process::exit(1);
panic!();
}
let entries = entries_result.unwrap();

Expand Down Expand Up @@ -107,7 +107,7 @@ impl Plugin {
target: self.plugin.id.as_str(),
"{:?}", error,
);
std::process::exit(1);
panic!();
}

loop {
Expand Down
8 changes: 4 additions & 4 deletions services/index-git-repositories/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn write_index_file(git_repository_paths: Vec<&str>) {
error = log::as_error!(error);
"Could read HOME environment variable",
);
std::process::exit(1);
panic!();
}
let home_directory = home_directory_result.unwrap();

Expand All @@ -54,7 +54,7 @@ fn write_index_file(git_repository_paths: Vec<&str>) {
error = log::as_error!(error);
"Error while creating cache directory",
);
std::process::exit(1);
panic!();
}

let index_file_path = cache_directory_path.join("git-repositories-index.json");
Expand All @@ -65,7 +65,7 @@ fn write_index_file(git_repository_paths: Vec<&str>) {
error = log::as_error!(error);
"Error while creating index file",
);
std::process::exit(1);
panic!();
}
let index_file = index_file_result.unwrap();

Expand All @@ -75,6 +75,6 @@ fn write_index_file(git_repository_paths: Vec<&str>) {
error = log::as_error!(error);
"Error while writing index file",
);
std::process::exit(1);
panic!();
}
}

0 comments on commit fbc1da1

Please sign in to comment.