summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-04-02 08:58:48 +0300
committerLars Wirzenius <liw@liw.fi>2022-04-10 15:27:08 +0300
commita3d768162e70004d207a40d803f5d17eeea8593a (patch)
tree3f65bc109526f0dc69861cd0ee995e2ca5ccefea /src/error.rs
parent68c09d2407b329ac03fcd9f25ba293a3a6201689 (diff)
downloadsubplot-a3d768162e70004d207a40d803f5d17eeea8593a.tar.gz
refactor: collect warnings for a document in its Document
Change places where warnings used to be written out so the warnings are pushed into the list in Document instead. Sponsored-by: author
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index bcee4ff..31fca60 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -334,3 +334,39 @@ impl SubplotError {
/// A result type for this crate.
pub type Result<T> = std::result::Result<T, SubplotError>;
+
+/// A warning, or non-fatal error.
+///
+/// Errors prevent Subplot from producing output. Warnings don't do that.
+#[derive(Debug)]
+pub enum Warning {
+ /// Document refers to an embedded file that doesn't exist.
+ UnknownEmbeddedFile(String),
+
+ /// Embedded file is not used by any scenario.
+ UnusedEmbeddedFile(String),
+
+ /// Missing step implementation.
+ MissingStepImplementation(String),
+}
+
+/// A list of warnings.
+///
+/// Subplot collects warnings into this structure so that they can be
+/// processed at the end.
+#[derive(Debug, Default)]
+pub struct Warnings {
+ warnings: Vec<Warning>,
+}
+
+impl Warnings {
+ /// Append a warning to the list.
+ pub fn push(&mut self, w: Warning) {
+ self.warnings.push(w);
+ }
+
+ /// Return a slice with all the warnings in the list.
+ pub fn warnings(&self) -> &[Warning] {
+ &self.warnings
+ }
+}