Skip to content

Commit 537f77d

Browse files
committed
log: display client error messages when possible as warnings
This should help demystify some cases when client errors are determined by parsing and propagated via `?`.
1 parent cab2065 commit 537f77d

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/log/middleware.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,22 @@ impl LogMiddleware {
6565
});
6666
}
6767
} else if status.is_client_error() {
68-
log::warn!("--> Response sent", {
69-
method: method,
70-
path: path,
71-
status: status as u16,
72-
duration: format!("{:?}", start.elapsed()),
73-
});
68+
if let Some(error) = response.error() {
69+
log::warn!("Client error --> Response sent", {
70+
message: error.to_string(),
71+
method: method,
72+
path: path,
73+
status: status as u16,
74+
duration: format!("{:?}", start.elapsed()),
75+
});
76+
} else {
77+
log::warn!("Client error --> Response sent", {
78+
method: method,
79+
path: path,
80+
status: status as u16,
81+
duration: format!("{:?}", start.elapsed()),
82+
});
83+
}
7484
} else {
7585
log::info!("--> Response sent", {
7686
method: method,

0 commit comments

Comments
 (0)