validation: change error enum names to be more descriptive

This commit is contained in:
Quaternions 2024-12-10 17:47:17 -08:00
parent c029939ee2
commit 24e88c5a0a

View File

@ -7,8 +7,8 @@ mod publish_fix;
#[derive(Debug)] #[derive(Debug)]
enum StartupError{ enum StartupError{
API(api::ReqwestError), API(api::ReqwestError),
Connect(async_nats::ConnectError), NatsConnect(async_nats::ConnectError),
Subscribe(async_nats::SubscribeError), NatsSubscribe(async_nats::SubscribeError),
} }
impl std::fmt::Display for StartupError{ impl std::fmt::Display for StartupError{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
@ -31,7 +31,7 @@ async fn main()->Result<(),StartupError>{
// nats // nats
let nats_host=std::env::var("NATS_HOST").expect("NATS_HOST env required"); let nats_host=std::env::var("NATS_HOST").expect("NATS_HOST env required");
let nasty=async_nats::connect(nats_host).await.map_err(StartupError::Connect)?; let nasty=async_nats::connect(nats_host).await.map_err(StartupError::NatsConnect)?;
// connect to nats // connect to nats
let (publish_new,publish_fix,validator)=tokio::try_join!( let (publish_new,publish_fix,validator)=tokio::try_join!(
@ -40,7 +40,7 @@ async fn main()->Result<(),StartupError>{
// clone nats here because it's dropped within the function scope, // clone nats here because it's dropped within the function scope,
// meanining the last reference is dropped... // meanining the last reference is dropped...
validator::Validator::new(nasty.clone(),cookie_context,api) validator::Validator::new(nasty.clone(),cookie_context,api)
).map_err(StartupError::Subscribe)?; ).map_err(StartupError::NatsSubscribe)?;
// publisher threads // publisher threads
tokio::spawn(publish_new.run()); tokio::spawn(publish_new.run());