Add error handling for configuration conversion to regex rules

This commit is contained in:
Richard Weber 2024-08-15 17:36:42 +03:00 committed by Victoria Brekenfeld
parent e8947b8742
commit ec86fc33e0
2 changed files with 13 additions and 7 deletions

View file

@ -55,14 +55,14 @@ pub fn is_dialog(window: &CosmicSurface) -> bool {
false
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct TilingExceptions {
app_ids: RegexSet,
titles: RegexSet,
}
impl TilingExceptions {
pub fn new(config: &Config) -> Self {
pub fn new(config: &Config) -> Result<Self, regex::Error> {
let mut app_ids = Vec::new();
let mut titles = Vec::new();
@ -73,10 +73,10 @@ impl TilingExceptions {
}
}
Self {
app_ids: RegexSet::new(app_ids).unwrap(),
titles: RegexSet::new(titles).unwrap(),
}
Ok(Self {
app_ids: RegexSet::new(app_ids)?,
titles: RegexSet::new(titles)?,
})
}
}