refactor: simplify error handling and remove unnecessary else statements

This commit is contained in:
Tunglies
2025-08-17 13:24:52 +08:00
parent 5b6d6aaa91
commit 099163450f
10 changed files with 23 additions and 378 deletions
+1 -2
View File
@@ -121,9 +121,8 @@ pub async fn download_icon_cache(url: String, name: String) -> CmdResult<String>
Err(_) => {
if icon_path.exists() {
return Ok(icon_path.to_string_lossy().to_string());
} else {
return Err("Failed to create temporary file".into());
}
return Err("Failed to create temporary file".into());
}
};
+10 -11
View File
@@ -1091,18 +1091,17 @@ async fn check_disney_plus(client: &Client) -> UnlockItem {
region: None,
check_time: Some(get_local_date_string()),
};
} else {
return UnlockItem {
name: "Disney+".to_string(),
status: format!(
"Failed (GraphQL error: {}, status: {})",
graphql_body_text.chars().take(50).collect::<String>() + "...",
graphql_status.as_u16()
),
region: None,
check_time: Some(get_local_date_string()),
};
}
return UnlockItem {
name: "Disney+".to_string(),
status: format!(
"Failed (GraphQL error: {}, status: {})",
graphql_body_text.chars().take(50).collect::<String>() + "...",
graphql_status.as_u16()
),
region: None,
check_time: Some(get_local_date_string()),
};
}
// 提取国家代码