specify listener in error messages and logs

The "listening for incoming traffic on ..." log line is new, but
something I've wanted even when we only supported one listener.

I considered getting rid of `clippy::too_many_lines` by factoring out
the construction of `app` to a separate function, but found that
specifying it's type (or relevant traits) got quite hairy.
This commit is contained in:
Benjamin Lee 2024-06-08 12:52:13 -07:00
parent f7d7952f9b
commit 4f041f9153
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
3 changed files with 36 additions and 11 deletions

View file

@ -4,6 +4,8 @@ use std::{fmt, iter, path::PathBuf};
use thiserror::Error;
use crate::config::ListenConfig;
/// Formats an [`Error`][0] and its [`source`][1]s with a separator
///
/// [0]: std::error::Error
@ -108,10 +110,10 @@ pub(crate) enum Serve {
NoListeners,
#[error(
"listener requested TLS, but no TLS cert was specified in the \
"listener {0} requested TLS, but no TLS cert was specified in the \
configuration file. Please set 'tls.certs' and 'tls.key'"
)]
NoTlsCerts,
NoTlsCerts(ListenConfig),
#[error("failed to read TLS cert and key files at {certs:?} and {key:?}")]
LoadCerts {
@ -121,6 +123,6 @@ pub(crate) enum Serve {
err: std::io::Error,
},
#[error("failed to run request listener")]
Listen(#[source] std::io::Error),
#[error("failed to run request listener on {1}")]
Listen(#[source] std::io::Error, ListenConfig),
}