added errors to upload when tilera breaks the api and makes it return nonsense
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d7c0831c85
commit
a4d66b1fbe
1 changed files with 13 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use anyhow::Result;
|
use anyhow::{Result, bail};
|
||||||
use jm_client_core::{api::UpResp, JMClient};
|
use jm_client_core::{api::UpResp, JMClient};
|
||||||
use log::info;
|
use log::info;
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
|
@ -39,7 +39,18 @@ pub async fn run(
|
||||||
|
|
||||||
let status = res.status();
|
let status = res.status();
|
||||||
// TODO move into JMClient
|
// TODO move into JMClient
|
||||||
let res = serde_json::from_slice::<UpResp>(&res.bytes().await?)?;
|
let bytes = &res.bytes().await?;
|
||||||
|
|
||||||
|
let res = if let Ok(res) = serde_json::from_slice::<UpResp>(bytes) {
|
||||||
|
res
|
||||||
|
} else {
|
||||||
|
if let Ok(s) = std::str::from_utf8(bytes) {
|
||||||
|
bail!("Server responded with unexpected response: {}", s);
|
||||||
|
} else {
|
||||||
|
bail!("Server responded with invalid utf8 bytes: {:?}", bytes);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
println!("Server responded with code {}", status);
|
println!("Server responded with code {}", status);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue