From 0d1c6a752c831816de8850927dc9a521a7e8bcee Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 16 Aug 2021 00:57:23 +0100 Subject: [PATCH] reporter: introduce TooManyWarnings Signed-off-by: Ian Jackson --- src/reporter.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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()); } } -- 2.30.2