diff --git a/src/group.rs b/src/group.rs index 668f099..d203029 100644 --- a/src/group.rs +++ b/src/group.rs @@ -79,11 +79,20 @@ impl Group { let mut sections = HashSet::new(); while lines.peek().is_some() { - if let Ok(section) = Section::try_from_lines(&mut lines).context("reading section") { - sections.insert(section); + match Section::try_from_lines(&mut lines).context("reading section") { + Ok(section) => { + sections.insert(section); + } + Err(e) => { + println!("WARNING: could not process a section under group '{name}': {e:?}\n") + } } } + if sections.is_empty() { + println!("WARNING: no sections found in group '{name}'"); + } + Ok(Self { name, sections }) } } diff --git a/src/section.rs b/src/section.rs index b7ac8fa..96df643 100644 --- a/src/section.rs +++ b/src/section.rs @@ -5,7 +5,7 @@ use std::{ iter::Peekable, }; -use anyhow::{Context, Result}; +use anyhow::{ensure, Context, Result}; use crate::Package; @@ -38,6 +38,9 @@ impl Section { packages.insert(package); } } + + ensure!(!packages.is_empty()); + Ok(Self::new(name, packages)) } }