Skip to content

Commit

Permalink
Log a warning when an article is missing a valid price
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Oct 28, 2024
1 parent d7c41e0 commit 4a91dfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions firmware/src/article.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::string::String;

/// Article id
/// Equivalent to the Vereinsflieger `articleid` attribute
#[allow(clippy::module_name_repetitions)]
pub type ArticleId = u32;

Expand Down
6 changes: 6 additions & 0 deletions firmware/src/vereinsflieger/proto_articles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use alloc::vec::Vec;
use core::cell::RefCell;
use core::str::FromStr;
use embedded_io_async::{BufRead, Write};
use log::warn;

/// `articles/list` request
#[derive(Debug)]
Expand Down Expand Up @@ -57,6 +58,11 @@ impl<const N: usize> FromJsonObject for ArticleListResponse<N> {
// needed, which heavily reduces memory consumption.
let mut articles = context.borrow_mut();
articles.update(article.articleid, article.designation.clone(), price);
} else {
warn!(
"Ignoring article with no valid price ({}): {}",
article.articleid, article.designation
);
}
}
_ => _ = json.read_any().await?,
Expand Down

0 comments on commit 4a91dfb

Please sign in to comment.