[pdm-devel] [RFC PATCH datacenter-manager] server: api: resources: use root cause for errors for remote fetching
Dominik Csapak
d.csapak at proxmox.com
Tue Sep 9 10:25:51 CEST 2025
when we can't reach a remote for any reason, we want to return the error
as a string here over the API. Since most errors that can occur here are
client/network related (wrong credentials, no route to host, timeout,
etc.) converting this error directly to a string gives us
errors like:
`client error (Connect)`
which is not really helpful most of the time.
Instead if we use the `root_cause()`, we get the most underlying error
e.g.
`error connecting to https://0.0.0.0:8006/ - tcp connect error: No route to host (os error 113)`
which is much more helpful.
We could also think about printing the whole error chain, but in my test
cases here this was not more helpful, e.g. i got two times the above
`client error (Connect)` and once the root cause from above.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
server/src/api/resources.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/src/api/resources.rs b/server/src/api/resources.rs
index 98c4dea..cca8bcb 100644
--- a/server/src/api/resources.rs
+++ b/server/src/api/resources.rs
@@ -245,7 +245,7 @@ pub(crate) async fn get_resources_impl(
let handle = tokio::spawn(async move {
let (mut resources, error) = match get_resources_for_remote(remote, max_age).await {
Ok(resources) => (resources, None),
- Err(error) => (Vec::new(), Some(error.to_string())),
+ Err(error) => (Vec::new(), Some(error.root_cause().to_string())),
};
if remotes_only {
--
2.47.2
More information about the pdm-devel
mailing list