Add some context to parse errors

This commit is contained in:
Matteo Settenvini 2022-08-05 22:03:55 +02:00
parent 7495682e41
commit 5e796365f1
Signed by: matteo
GPG Key ID: 8576CC1AD97D42DF
2 changed files with 13 additions and 17 deletions

View File

@ -1,5 +1,5 @@
"day","wday","lunch","dinner" "day","wday","lunch","dinner"
"2022-01-01","sabato",, "2022-01-01","sabato",,"Ragù di carne"
"2022-01-02","domenica",, "2022-01-02","domenica",,
"2022-01-03","lunedì",, "2022-01-03","lunedì",,
"2022-01-04","martedì",, "2022-01-04","martedì",,
@ -33,7 +33,7 @@
"2022-02-01","martedì",, "2022-02-01","martedì",,
"2022-02-02","mercoledì",, "2022-02-02","mercoledì",,
"2022-02-03","giovedì",, "2022-02-03","giovedì",,
"2022-02-04","venerdì",, "2022-02-04","venerdì",,"Ragù di carne"
"2022-02-05","sabato",,"https://ricette.giallozafferano.it/Chili-con-carne.html" "2022-02-05","sabato",,"https://ricette.giallozafferano.it/Chili-con-carne.html"
"2022-02-06","domenica",, "2022-02-06","domenica",,
"2022-02-07","lunedì",, "2022-02-07","lunedì",,
@ -97,7 +97,7 @@
"2022-04-06","mercoledì",, "2022-04-06","mercoledì",,
"2022-04-07","giovedì",, "2022-04-07","giovedì",,
"2022-04-08","venerdì",,"https://ricette.giallozafferano.it/Ratatouille.html" "2022-04-08","venerdì",,"https://ricette.giallozafferano.it/Ratatouille.html"
"2022-04-09","sabato",, "2022-04-09","sabato",,"Ragù di carne"
"2022-04-10","domenica",, "2022-04-10","domenica",,
"2022-04-11","lunedì",, "2022-04-11","lunedì",,
"2022-04-12","martedì",, "2022-04-12","martedì",,
@ -258,7 +258,7 @@
"2022-09-14","mercoledì",,"https://ricette.giallozafferano.it/Scaloppine-ai-funghi.html" "2022-09-14","mercoledì",,"https://ricette.giallozafferano.it/Scaloppine-ai-funghi.html"
"2022-09-15","giovedì",, "2022-09-15","giovedì",,
"2022-09-16","venerdì",,"https://ricette.giallozafferano.it/Cordon-bleu-di-melanzane.html" "2022-09-16","venerdì",,"https://ricette.giallozafferano.it/Cordon-bleu-di-melanzane.html"
"2022-09-17","sabato",, "2022-09-17","sabato",,"Ragù di carne"
"2022-09-18","domenica",, "2022-09-18","domenica",,
"2022-09-19","lunedì",, "2022-09-19","lunedì",,
"2022-09-20","martedì",, "2022-09-20","martedì",,
@ -300,7 +300,7 @@
"2022-10-26","mercoledì",, "2022-10-26","mercoledì",,
"2022-10-27","giovedì",, "2022-10-27","giovedì",,
"2022-10-28","venerdì",,"https://ricette.giallozafferano.it/Vellutata-di-zucca-e-carote.html" "2022-10-28","venerdì",,"https://ricette.giallozafferano.it/Vellutata-di-zucca-e-carote.html"
"2022-10-29","sabato","https://ricette.giallozafferano.it/Orata-al-forno.html", "2022-10-29","sabato","https://ricette.giallozafferano.it/Orata-al-forno.html","Ragù di carne"
"2022-10-30","domenica",, "2022-10-30","domenica",,
"2022-10-31","lunedì",, "2022-10-31","lunedì",,
"2022-11-01","martedì",, "2022-11-01","martedì",,
@ -342,7 +342,7 @@
"2022-12-07","mercoledì",,"https://ricette.giallozafferano.it/Involtini-di-cotoletta.html" "2022-12-07","mercoledì",,"https://ricette.giallozafferano.it/Involtini-di-cotoletta.html"
"2022-12-08","giovedì",, "2022-12-08","giovedì",,
"2022-12-09","venerdì",, "2022-12-09","venerdì",,
"2022-12-10","sabato","https://ricette.giallozafferano.it/Gnudi.html", "2022-12-10","sabato","https://ricette.giallozafferano.it/Gnudi.html","Ragù di carne"
"2022-12-11","domenica",, "2022-12-11","domenica",,
"2022-12-12","lunedì",, "2022-12-12","lunedì",,
"2022-12-13","martedì",, "2022-12-13","martedì",,

1 day wday lunch dinner
2 2022-01-01 sabato Ragù di carne
3 2022-01-02 domenica
4 2022-01-03 lunedì
5 2022-01-04 martedì
33 2022-02-01 martedì
34 2022-02-02 mercoledì
35 2022-02-03 giovedì
36 2022-02-04 venerdì Ragù di carne
37 2022-02-05 sabato https://ricette.giallozafferano.it/Chili-con-carne.html
38 2022-02-06 domenica
39 2022-02-07 lunedì
97 2022-04-06 mercoledì
98 2022-04-07 giovedì
99 2022-04-08 venerdì https://ricette.giallozafferano.it/Ratatouille.html
100 2022-04-09 sabato Ragù di carne
101 2022-04-10 domenica
102 2022-04-11 lunedì
103 2022-04-12 martedì
258 2022-09-14 mercoledì https://ricette.giallozafferano.it/Scaloppine-ai-funghi.html
259 2022-09-15 giovedì
260 2022-09-16 venerdì https://ricette.giallozafferano.it/Cordon-bleu-di-melanzane.html
261 2022-09-17 sabato Ragù di carne
262 2022-09-18 domenica
263 2022-09-19 lunedì
264 2022-09-20 martedì
300 2022-10-26 mercoledì
301 2022-10-27 giovedì
302 2022-10-28 venerdì https://ricette.giallozafferano.it/Vellutata-di-zucca-e-carote.html
303 2022-10-29 sabato https://ricette.giallozafferano.it/Orata-al-forno.html Ragù di carne
304 2022-10-30 domenica
305 2022-10-31 lunedì
306 2022-11-01 martedì
342 2022-12-07 mercoledì https://ricette.giallozafferano.it/Involtini-di-cotoletta.html
343 2022-12-08 giovedì
344 2022-12-09 venerdì
345 2022-12-10 sabato https://ricette.giallozafferano.it/Gnudi.html Ragù di carne
346 2022-12-11 domenica
347 2022-12-12 lunedì
348 2022-12-13 martedì

View File

@ -7,7 +7,7 @@ use {
crate::recipe, crate::recipe,
crate::scheduling::{Meal, Scheduling}, crate::scheduling::{Meal, Scheduling},
crate::{constants, helpers}, crate::{constants, helpers},
anyhow::{bail, Result}, anyhow::{anyhow, bail, Result},
chrono::naive::NaiveDate, chrono::naive::NaiveDate,
futures::future::try_join_all, futures::future::try_join_all,
icalendar::Event, icalendar::Event,
@ -93,17 +93,13 @@ async fn get_all_recipes(api_client: &ApiClient) -> Result<HashMap<String, Rc<re
.await?; .await?;
let recipes = metadata.iter().map(|rm| async { let recipes = metadata.iter().map(|rm| async {
let response = api_client let recipe_url = api_client
.rest(|client| async {
let r = client
.get(
api_client
.base_url() .base_url()
.join(&format!("apps/cookbook/api/recipes/{id}", id = rm.id)) .join(&format!("apps/cookbook/api/recipes/{id}", id = rm.id))
.unwrap(), .unwrap();
) let response = api_client
.send() .rest(|client| async {
.await; let r = client.get(recipe_url.clone()).send().await;
Ok(r?) Ok(r?)
}) })
.await?; .await?;
@ -112,7 +108,7 @@ async fn get_all_recipes(api_client: &ApiClient) -> Result<HashMap<String, Rc<re
.json::<recipe::Recipe>() .json::<recipe::Recipe>()
.await .await
.map(|r| Rc::new(r)) .map(|r| Rc::new(r))
.map_err(|err| anyhow::anyhow!(err)) .map_err(|err| anyhow!(err).context(format!("while fetching {}", recipe_url)))
}); });
let recipes = try_join_all(recipes).await?; let recipes = try_join_all(recipes).await?;