Skip to content

Commit fcd9729

Browse files
better error for when create_or_get_video fails
1 parent 33ffc7d commit fcd9729

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apps/desktop/src-tauri/src/upload.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,21 @@ pub async fn create_or_get_video(
236236
error: String,
237237
}
238238

239-
if let Ok(error) = response.json::<CreateErrorResponse>().await {
239+
let status = response.status();
240+
let body = response.text().await;
241+
242+
if let Some(error) = body
243+
.as_ref()
244+
.ok()
245+
.and_then(|body| serde_json::from_str::<CreateErrorResponse>(&*body).ok())
246+
&& status == StatusCode::FORBIDDEN
247+
{
240248
if error.error == "upgrade_required" {
241249
return Err(AuthedApiError::UpgradeRequired);
242250
}
243251
}
244252

245-
return Err("Unknown error uploading video".into());
253+
return Err(format!("create_or_get_video/error/{status}: {body:?}").into());
246254
}
247255

248256
let response_text = response

0 commit comments

Comments
 (0)