mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-10 16:01:20 +00:00
improve client error message
This commit is contained in:
@@ -139,13 +139,18 @@ async fn handle_req<Res: DeserializeOwned>(
|
||||
|
||||
let status = res.status();
|
||||
|
||||
if status == StatusCode::OK {
|
||||
if status.is_success() {
|
||||
res.json().await.context("failed to parse response to json")
|
||||
} else {
|
||||
let text = res
|
||||
.text()
|
||||
.await
|
||||
.context("failed to get response body as text")?;
|
||||
if let Ok(json_error) =
|
||||
serde_json::from_str::<serde_json::Value>(&text)
|
||||
{
|
||||
return Err(anyhow!("{status} | {json_error:?}"));
|
||||
}
|
||||
Err(anyhow!("{status} | {text}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,8 +150,9 @@ pub enum HetznerVolumeFormat {
|
||||
)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum HetznerServerType {
|
||||
#[default]
|
||||
SharedIntel1Core2Ram20Disk,
|
||||
// The lowest tier available at all locations
|
||||
#[default]
|
||||
SharedAmd2Core2Ram40Disk,
|
||||
SharedArm2Core4Ram40Disk,
|
||||
SharedIntel2Core4Ram40Disk,
|
||||
|
||||
Reference in New Issue
Block a user