File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -149,10 +149,26 @@ impl Middleware for LoggingMiddleware {
149
149
let result = next. run ( req, extensions) . await ;
150
150
151
151
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
+ )
154
170
} else {
155
- error . to_string ( )
171
+ error_chain [ 0 ] . clone ( )
156
172
} ;
157
173
158
174
log:: warn!( "error {method} {url} -> {error_details}" ) ;
You can’t perform that action at this time.
0 commit comments