Skip to content

Commit c50ba75

Browse files
authored
fix: handle tmdb errors (#125)
2 parents 1d4312c + 995b393 commit c50ba75

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/trakt.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,17 @@ impl Trakt {
120120
MediaType::Show => format!("https://api.themoviedb.org/3/tv/{tmdb_id}/season/{season_id}/images?api_key={tmdb_token}")
121121
};
122122

123-
let response = self
124-
.agent
125-
.get(&endpoint)
126-
.call()
127-
.expect("TMDB API call failed");
123+
let response = self.agent.get(&endpoint).call();
124+
125+
if response.is_err() {
126+
log(&format!(
127+
"{} image not correctly found",
128+
media_type.as_str()
129+
));
130+
return None;
131+
}
128132

129-
match response.into_json::<serde_json::Value>() {
133+
match response.unwrap().into_json::<serde_json::Value>() {
130134
Ok(body) => {
131135
if body["posters"].as_array().unwrap_or(&vec![]).is_empty() {
132136
log("Show image not correctly found");

0 commit comments

Comments
 (0)