From ccb9c9954fae2f3a5fc955f3734987bfe6e02aa6 Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Fri, 5 May 2023 22:40:17 +0200 Subject: in case of http errors, print the response text --- src/main.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 3b434c0..8e5bb2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -166,11 +166,19 @@ fn update_instance(args: Args) -> anyhow::Result<()> { } fn upload(clt: &Client, dst: Url, buf: Vec) -> anyhow::Result<()> { - clt.put(dst) + let resp = clt + .put(dst) .header(CONTENT_TYPE, "application/octet-stream") .body(buf) - .send()? - .error_for_status()?; + .send()?; + + match resp.error_for_status_ref() { + Ok(_) => {} + Err(e) => { + println!("Rustkrazy instance returned an error: {}", resp.text()?); + return Err(e.into()); + } + } Ok(()) } -- cgit v1.2.3