diff --git a/src/run/uploader/interfaces.rs b/src/run/uploader/interfaces.rs index 66943aa..72423d8 100644 --- a/src/run/uploader/interfaces.rs +++ b/src/run/uploader/interfaces.rs @@ -35,3 +35,9 @@ pub struct UploadData { pub upload_url: String, pub run_id: String, } + +#[derive(Deserialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct UploadError { + pub error: String, +} diff --git a/src/run/uploader/upload.rs b/src/run/uploader/upload.rs index 9b98003..fbaf9f0 100644 --- a/src/run/uploader/upload.rs +++ b/src/run/uploader/upload.rs @@ -1,3 +1,4 @@ +use crate::run::uploader::UploadError; use crate::run::{ check_system::SystemInfo, ci_provider::CIProvider, config::Config, runner::RunData, }; @@ -41,10 +42,15 @@ async fn retrieve_upload_data( match response { Ok(response) => { if response.status().is_client_error() { + let status = response.status(); + let text = response.text().await?; + let error_message = serde_json::from_str::(&text) + .map(|body| body.error) + .unwrap_or(text); bail!( - "Failed to retrieve upload data: {} {}", - response.status(), - response.text().await? + "Failed to retrieve upload data: {}\n{}", + status, + error_message ); }