From: Ian Jackson Date: Sun, 15 Aug 2021 23:57:23 +0000 (+0100) Subject: reporter: introduce TooManyWarnings X-Git-Tag: hippotat/1.0.0~149 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=0d1c6a752c831816de8850927dc9a521a7e8bcee;p=hippotat.git reporter: introduce TooManyWarnings Signed-off-by: Ian Jackson --- diff --git a/src/reporter.rs b/src/reporter.rs index 4f72c35..6f4fb0d 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -204,12 +204,14 @@ pub struct Warnings { pub warnings: Vec, } +#[derive(Debug,Error)] +#[error("too many warnings")] +pub struct TooManyWarnings; + impl Warnings { - #[throws(AE)] + #[throws(TooManyWarnings)] pub fn add(&mut self, e: &dyn Display) { - if self.warnings.len() >= MAX_WARNINGS { - throw!(anyhow!("too many warnings")) - } + if self.warnings.len() >= MAX_WARNINGS { throw!(TooManyWarnings) } self.warnings.push(e.to_string()); } }