Skip to content

Commit

Permalink
fix: return error if upload failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Lilleengen committed Oct 3, 2023
1 parent e8c1868 commit b66b44a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions admin/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,11 @@ async fn upload(
builder = builder.inject_token(provider).await?;
builder = builder.body(data);

match builder.send().await {
Ok(r) if r.status() == StatusCode::OK || r.status() == StatusCode::CREATED => {
log::info!("Upload successful");
}
Ok(r) => {
log::warn!("Failed to upload document: {}", r.status());
}
Err(e) => {
log::warn!("Failed to upload document: {e}");
}
let r = builder.send().await?;
if r.status() == StatusCode::OK || r.status() == StatusCode::CREATED {
log::info!("Upload successful");
Ok(())
} else {
Err(anyhow::anyhow!("Upload failed: {}", r.status()))
}
Ok(())
}

0 comments on commit b66b44a

Please sign in to comment.