From 5d9a3380c8c1384a53ea2ad007a5cdfc7baabdfd Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Fri, 12 May 2023 00:36:03 +0200 Subject: refactor: Handle error if JSON not well-formatted for release notes (#348) Handle error if JSON not well-formatted for release notes We usually shouldn't hit this cause GitHub shouldn't server broken JSON and if connection failed we should error out earlier yet this was logged on Sentry. --- src-tauri/src/github/release_notes.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src-tauri/src') diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs index b45442e0..4ff075bd 100644 --- a/src-tauri/src/github/release_notes.rs +++ b/src-tauri/src/github/release_notes.rs @@ -96,8 +96,13 @@ pub async fn get_northstar_release_notes() -> Result, String> { let url = "https://api.github.com/repos/R2Northstar/Northstar/releases"; let res = fetch_github_releases_api(url).await?; - let release_info_vector: Vec = - serde_json::from_str(&res).expect("JSON was not well-formatted"); + let release_info_vector: Vec = match serde_json::from_str(&res) { + Ok(res) => res, + Err(err) => { + log::warn!("{err}"); + return Err("Could not fetch release notes. JSON was not well-formatted".to_string()); + } + }; log::info!("Done checking GitHub API"); Ok(release_info_vector) -- cgit v1.2.3