printear errores asap

This commit is contained in:
Cat /dev/Nulo 2024-03-11 12:16:18 -03:00
parent 855c2c6799
commit d93d5c2055

View file

@ -3,14 +3,13 @@ use chrono::{DateTime, Utc};
use clap::{Parser, ValueEnum}; use clap::{Parser, ValueEnum};
use cron::Schedule; use cron::Schedule;
use db::Db; use db::Db;
use futures::{future, stream, Future, StreamExt}; use futures::{future, stream, Future, StreamExt, TryFutureExt};
use nanoid::nanoid;
use reqwest::{header::HeaderMap, StatusCode, Url}; use reqwest::{header::HeaderMap, StatusCode, Url};
use simple_error::{bail, SimpleError}; use simple_error::{bail, SimpleError};
use std::{ use std::{
env::{self}, env::{self},
fs, fs,
path::PathBuf,
str::FromStr, str::FromStr,
time::{Duration, SystemTime, UNIX_EPOCH}, time::{Duration, SystemTime, UNIX_EPOCH},
}; };
@ -425,7 +424,16 @@ async fn auto_cli(args: AutoArgs) -> anyhow::Result<()> {
let handles: Vec<_> = supermercados let handles: Vec<_> = supermercados
.iter() .iter()
.map(|s| tokio::spawn(auto.clone().download_supermercado(s.to_owned()))) .map(|s| {
let x = s.clone();
tokio::spawn(
auto.clone()
.download_supermercado(s.to_owned())
.inspect_err(move |err| {
tracing::error!(error=%err, supermercado=?x);
}),
)
})
.collect(); .collect();
future::try_join_all(handles).await?; future::try_join_all(handles).await?;
auto.inform("[auto] Download supermercados finished").await; auto.inform("[auto] Download supermercados finished").await;