Skip to content

Commit 653cba3

Browse files
authored
fix: improve error logging in FFI HTTP middleware to capture full error chain (#1259)
1 parent 47ceacc commit 653cba3

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

flipt-engine-ffi/src/http.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,26 @@ impl Middleware for LoggingMiddleware {
149149
let result = next.run(req, extensions).await;
150150

151151
if let Err(error) = &result {
152-
let error_details = if let Some(source) = StdError::source(error) {
153-
format!("{error} (source: {source})")
152+
// Build complete error chain
153+
let mut error_chain = Vec::new();
154+
error_chain.push(error.to_string());
155+
156+
let mut current_error: Option<&dyn StdError> = error.source();
157+
while let Some(source) = current_error {
158+
// Use Debug format for complete error information
159+
// This ensures we capture all error details, even for types with poor Display implementations
160+
error_chain.push(format!("{source:?}"));
161+
current_error = source.source();
162+
}
163+
164+
let error_details = if error_chain.len() > 1 {
165+
format!(
166+
"{} (caused by: {})",
167+
error_chain[0],
168+
error_chain[1..].join(" -> ")
169+
)
154170
} else {
155-
error.to_string()
171+
error_chain[0].clone()
156172
};
157173

158174
log::warn!("error {method} {url} -> {error_details}");

0 commit comments

Comments
 (0)