From e4ae8a22409b7c369bdb087e72279f27c74188be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Sun, 7 Apr 2024 16:17:17 +0800 Subject: [PATCH] feat(debug): add support for debug message --- src/models/server.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/models/server.rs b/src/models/server.rs index c368d16..ff7b05d 100644 --- a/src/models/server.rs +++ b/src/models/server.rs @@ -133,13 +133,15 @@ async fn _handle( .await { Ok(status_code) => status_code, - Err(_) => { - return Err(anyhow!(OblivionException::ServerError { - method: request.get_method(), - ipaddr: request.get_ip(), - olps: request.get_olps(), - status_code: 501, - })); + Err(error) => { + eprintln!( + "Oblivion/1.1 {} From {} {} {}", + request.get_method(), + request.get_ip(), + request.get_olps(), + 501 + ); + return Err(Error::from(error)); } }; @@ -161,7 +163,7 @@ pub async fn handle(router: Router, stream: TcpStream, peer: SocketAddr) { status_code ); } - Err(error) => println!("{}", error), + Err(error) => eprintln!("{}", error), } } @@ -187,7 +189,7 @@ impl Server { let tcp = match TcpListener::bind(format!("{}:{}", self.host, self.port)).await { Ok(tcp) => tcp, Err(_) => { - println!( + eprintln!( "{}", OblivionException::AddressAlreadyInUse { ipaddr: self.host.clone(),