From 038fc8af4ba9f9636edcf18ad3f1690330bd021a Mon Sep 17 00:00:00 2001 From: GiovanniTorrisi-ChainSecurity Date: Mon, 16 Jun 2025 09:51:40 +0200 Subject: [PATCH] Log error chain on communication error --- lib/dvf/parse.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/dvf/parse.rs b/lib/dvf/parse.rs index dcc37aeb..7fa88116 100644 --- a/lib/dvf/parse.rs +++ b/lib/dvf/parse.rs @@ -1,5 +1,6 @@ use std::collections::HashSet; use std::env::VarError; +use std::error::Error; use std::fmt; use std::fs::File; use std::io; @@ -126,6 +127,26 @@ impl From for ValidationError { impl From for ValidationError { fn from(error: reqwest::Error) -> Self { + // Print the full error details + eprintln!("Request failed: {:?}", error); + + // Optionally, print more specific causes + if error.is_timeout() { + eprintln!("Reason: Timeout"); + } else if error.is_connect() { + eprintln!("Reason: Connection error"); + } else if error.is_status() { + eprintln!("Reason: Received bad HTTP status"); + } else if error.is_request() { + eprintln!("Reason: Request failed to build"); + } + + // Print source chain (if available) + let mut source = error.source(); + while let Some(s) = source { + eprintln!("Caused by: {}", s); + source = s.source(); + } ValidationError::Error(format!("Communication error occurred: {}", error)) } }