Skip to content

Commit 1ef9aae

Browse files
committed
优化错误处理逻辑,简化超时和其他错误的日志记录
1 parent d9394b6 commit 1ef9aae

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

rust_http_proxy/src/forward_proxy_client.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,15 @@ where
297297
}
298298

299299
fn handle_http1_connection_error(err: hyper::Error, access_label: AccessLabel) {
300-
if let Some(source) = err.source() {
301-
if let Some(io_err) = source.downcast_ref::<io::Error>() {
302-
if io_err.kind() == ErrorKind::TimedOut {
303-
// 由于超时导致的连接关闭(TimeoutIO)
304-
info!("[legacy proxy connection io closed]: [{}] {} to {}", io_err.kind(), io_err, access_label);
305-
} else {
306-
warn!("[legacy proxy io error]: [{}] {} to {}", io_err.kind(), io_err, access_label);
307-
}
300+
if let Some(io_err) = err.source().and_then(|s| s.downcast_ref::<io::Error>()) {
301+
if io_err.kind() == ErrorKind::TimedOut {
302+
// 由于超时导致的连接关闭(TimeoutIO)
303+
info!("[legacy proxy connection io closed]: [{}] {} to {}", io_err.kind(), io_err, access_label);
308304
} else {
309-
warn!("[legacy proxy io error]: [{source}] to {access_label}");
305+
warn!("[legacy proxy io error]: [{}] {} to {}", io_err.kind(), io_err, access_label);
310306
}
307+
} else if let Some(source) = err.source() {
308+
warn!("[legacy proxy io error]: [{source}] to {access_label}");
311309
} else {
312310
warn!("[legacy proxy io error] [{err}] to {access_label}");
313311
}

0 commit comments

Comments
 (0)