fix: surface server error in get_status and trim table output
- Include error field in get_status() ApiResponse so server error messages are surfaced instead of generic 'No status data returned' - Use trim_lines_end() on table output to match local mode formatting
This commit is contained in:
@@ -227,11 +227,17 @@ impl KeepClient {
|
|||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
struct ApiResponse {
|
struct ApiResponse {
|
||||||
data: Option<crate::common::status::StatusInfo>,
|
data: Option<crate::common::status::StatusInfo>,
|
||||||
|
error: Option<String>,
|
||||||
}
|
}
|
||||||
let response: ApiResponse = self.get_json("/api/status")?;
|
let response: ApiResponse = self.get_json("/api/status")?;
|
||||||
response
|
response.data.ok_or_else(|| {
|
||||||
.data
|
CoreError::Other(anyhow::anyhow!(
|
||||||
.ok_or_else(|| CoreError::Other(anyhow::anyhow!("No status data returned")))
|
"{}",
|
||||||
|
response
|
||||||
|
.error
|
||||||
|
.unwrap_or_else(|| "No status data returned".to_string())
|
||||||
|
))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_item_info(&self, id: i64) -> Result<ItemInfo, CoreError> {
|
pub fn get_item_info(&self, id: i64) -> Result<ItemInfo, CoreError> {
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ pub fn mode(
|
|||||||
path_table.add_row(vec!["Data", &status_info.paths.data]);
|
path_table.add_row(vec!["Data", &status_info.paths.data]);
|
||||||
path_table.add_row(vec!["Database", &status_info.paths.database]);
|
path_table.add_row(vec!["Database", &status_info.paths.database]);
|
||||||
println!("PATHS:");
|
println!("PATHS:");
|
||||||
println!("{path_table}");
|
println!(
|
||||||
|
"{}",
|
||||||
|
crate::modes::common::trim_lines_end(&path_table.trim_fmt())
|
||||||
|
);
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
// Configured meta plugins
|
// Configured meta plugins
|
||||||
@@ -56,7 +59,10 @@ pub fn mode(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
println!("META PLUGINS:");
|
println!("META PLUGINS:");
|
||||||
println!("{table}");
|
println!(
|
||||||
|
"{}",
|
||||||
|
crate::modes::common::trim_lines_end(&table.trim_fmt())
|
||||||
|
);
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +84,10 @@ pub fn mode(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
println!("COMPRESSION:");
|
println!("COMPRESSION:");
|
||||||
println!("{table}");
|
println!(
|
||||||
|
"{}",
|
||||||
|
crate::modes::common::trim_lines_end(&table.trim_fmt())
|
||||||
|
);
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user