Skip to content

Commit d8232fa

Browse files
refactor: Return error string instead of anyhow!() (#36)
All that is returned as the error type is a string so there's no point in using a custom error type when we can just have the error type be a string. Co-authored-by: Remy Raes <[email protected]>
1 parent 4e03230 commit d8232fa

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src-tauri/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn linux_checks_librs() -> Result<(), String> {
7272
}
7373

7474
/// Attempts to find the game install location
75-
pub fn find_game_install_location() -> Result<GameInstall, anyhow::Error> {
75+
pub fn find_game_install_location() -> Result<GameInstall, String> {
7676
// Attempt parsing Steam library directly
7777
match steamlocate::SteamDir::locate() {
7878
Some(mut steamdir) => {
@@ -107,9 +107,7 @@ pub fn find_game_install_location() -> Result<GameInstall, anyhow::Error> {
107107
}
108108
};
109109

110-
Err(anyhow!(
111-
"Could not auto-detect game install location! Please enter it manually."
112-
))
110+
Err("Could not auto-detect game install location! Please enter it manually.".to_string())
113111
}
114112

115113
/// Returns the current Northstar version number as a string

src-tauri/src/main.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,7 @@ fn main() {
9898
#[tauri::command]
9999
/// Wrapper for `find_game_install_location` as tauri doesn't allow passing `Result<>` types to front-end
100100
async fn find_game_install_location_caller() -> Result<GameInstall, String> {
101-
match find_game_install_location() {
102-
Ok(game_install) => Ok(game_install),
103-
Err(err) => {
104-
println!("{}", err);
105-
Err(err.to_string())
106-
}
107-
}
101+
find_game_install_location()
108102
}
109103

110104
#[tauri::command]

0 commit comments

Comments
 (0)