产物下载失败信息补上可诊断上下文
- 传输失败带上脱敏 URL 与底层错误 source 链 - 非成功状态补上状态码文案与脱敏 URL
This commit is contained in:
@@ -110,15 +110,22 @@ impl TripoProviderClient {
|
||||
.map_err(|_elapsed| artifact_stall_error(task_id, self.artifact_stall_timeout))?
|
||||
.map_err(|error| TripoError::Request {
|
||||
message: format!(
|
||||
"artifact download transport failure for task {task_id}: {}",
|
||||
transport_error_kind(&error)
|
||||
"artifact download transport failure for task {task_id}: {} from {} ({})",
|
||||
transport_error_kind(&error),
|
||||
url.redacted(),
|
||||
transport_error_source(&error),
|
||||
),
|
||||
status: None,
|
||||
})?;
|
||||
let status = response.status();
|
||||
if !status.is_success() {
|
||||
return Err(TripoError::Request {
|
||||
message: format!("artifact download failed for task {task_id}"),
|
||||
message: format!(
|
||||
"artifact download failed for task {task_id}: {} {} ({})",
|
||||
status.as_u16(),
|
||||
status.canonical_reason().unwrap_or("unknown status"),
|
||||
url.redacted(),
|
||||
),
|
||||
status: Some(status.as_u16()),
|
||||
});
|
||||
}
|
||||
@@ -183,6 +190,13 @@ fn transport_error_kind(error: &reqwest::Error) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// reqwest 的 `Display` 会带上完整 URL(含签名参数),排障只取 source 链。
|
||||
fn transport_error_source(error: &reqwest::Error) -> String {
|
||||
std::error::Error::source(error)
|
||||
.map(|source| source.to_string())
|
||||
.unwrap_or_else(|| "no source detail".to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::net::SocketAddr;
|
||||
|
||||
Reference in New Issue
Block a user