Skip to content

Commit

Permalink
better error displau
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 14, 2024
1 parent 6b788fd commit 0217b2d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/src/storage/commercial_license_trial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ pub async fn send_to_reacher(
if !res.status().is_success() {
let status = StatusCode::from_u16(res.status().as_u16())?;
let body: serde_json::Value = res.json().await?;
return Err(ReacherResponseError::new(status, body));

// Extract error message from the "error" field, if it exists, or
// else just return the whole body.
let error_body = body.get("error").unwrap_or(&body).to_owned();

return Err(ReacherResponseError::new(status, error_body));
}

let res = res.text().await?;
Expand Down

0 comments on commit 0217b2d

Please sign in to comment.