aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
authorcat_or_not <41955154+catornot@users.noreply.github.com>2023-04-29 19:37:42 -0400
committerGitHub <noreply@github.com>2023-04-30 01:37:42 +0200
commit9b44923e910be666bc287c03e8601486416f653b (patch)
tree9cf2805b1d7aec6c6768cc0eed74ae6ca65a9381 /src-tauri/src
parente38ab60e1e4f565f0dafdb7b539e386a390594d7 (diff)
downloadFlightCore-9b44923e910be666bc287c03e8601486416f653b.tar.gz
FlightCore-9b44923e910be666bc287c03e8601486416f653b.zip
refactor: Use error in `ParsedThunderstoreModString::FromStr` instead of panic (#295)
report error instead of panic
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/mod_management/mod.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index 728e72c0..25dea2bb 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -16,18 +16,18 @@ use app::GameInstall;
struct ParsedThunderstoreModString {
author_name: String,
mod_name: String,
- version: Option<String>,
+ version: String,
}
impl std::str::FromStr for ParsedThunderstoreModString {
- type Err = ();
+ type Err = &'static str; // todo use an better error management
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut parts = s.split('-');
- let author_name = parts.next().unwrap().to_string();
- let mod_name = parts.next().unwrap().to_string();
- let version = parts.next().map(|s| s.to_string());
+ let author_name = parts.next().ok_or("None value on author_name")?.to_string();
+ let mod_name = parts.next().ok_or("None value on mod_name")?.to_string();
+ let version = parts.next().ok_or("None value on version")?.to_string();
Ok(ParsedThunderstoreModString {
author_name,
@@ -268,7 +268,7 @@ async fn get_ns_mod_download_url(thunderstore_mod_string: &str) -> Result<String
"{}/{}/{}",
parsed_ts_mod_string.author_name,
parsed_ts_mod_string.mod_name,
- parsed_ts_mod_string.version.unwrap()
+ parsed_ts_mod_string.version
);
for ns_mod in index {