diff options
author | metamuffin <metamuffin@disroot.org> | 2023-11-15 10:52:38 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-11-15 10:52:38 +0100 |
commit | cd8dca8cd323347a96a6f9c31e7465377e6230d3 (patch) | |
tree | dfe02aa547009684d09031b8a61b1c90fb129575 | |
parent | b10a6ea207ee4bcdee51be2052359b999eeb7bcf (diff) | |
download | gnix-cd8dca8cd323347a96a6f9c31e7465377e6230d3.tar gnix-cd8dca8cd323347a96a6f9c31e7465377e6230d3.tar.bz2 gnix-cd8dca8cd323347a96a6f9c31e7465377e6230d3.tar.zst |
better logging
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 0fb9957..d11bfe1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use crate::{ files::serve_files, proxy::proxy_request, }; -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{bail, Context, Result}; use bytes::Bytes; use config::setup_file_watch; use error::ServiceError; @@ -61,9 +61,10 @@ pub type FilterResponse = Option<Response<BoxBody<Bytes, ServiceError>>>; async fn main() -> anyhow::Result<()> { env_logger::init_from_env("LOG"); - let config_path = std::env::args().skip(1).next().ok_or(anyhow!( - "first argument is expected to be the configuration file" - ))?; + let Some(config_path) = std::env::args().skip(1).next() else { + eprintln!("error: first argument is expected to be the configuration file"); + exit(1) + }; let config = match Config::load(&config_path) { Ok(c) => c, @@ -189,6 +190,7 @@ pub async fn serve_stream<T: Unpin + Send + 'static + hyper::rt::Read + hyper::r Ok(r) => Ok(r), Err(ServiceError::Hyper(e)) => Err(e), Err(error) => Ok({ + debug!("service error {error:?}"); let mut resp = Response::new(format!( "Sorry, we were unable to process your request: {error}" )); |