summaryrefslogtreecommitdiff
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs83
1 files changed, 34 insertions, 49 deletions
diff --git a/src/error.rs b/src/error.rs
index c93141e..a42298d 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -259,60 +259,48 @@ pub enum SubplotError {
#[error("no scenarios were found matching the `{0}` template")]
NoScenariosMatched(String),
- /// I/O error
- ///
- /// Subplot did some I/O, and it failed. This is a generic wrapper
- /// for any kind of I/O error.
- #[error(transparent)]
- IoError {
- /// The wrapped error.
- #[from]
- source: std::io::Error,
- },
+ /// Failed to invoke a program.
+ #[error("Failed to invoke {0}")]
+ Spawn(PathBuf, #[source] std::io::Error),
- /// Pandoc error
- ///
- /// Subplot got an error from Panoc. This is a generic wrapper for
- /// any kinds of Pandoc errors.
- #[error(transparent)]
- PandocError {
- /// The wrapped error.
- #[from]
- source: pandoc::PandocError,
- },
+ /// Failed to write to stdin of child process.
+ #[error("Failed to write to stdin of child process")]
+ WriteToChild(#[source] std::io::Error),
+
+ /// Error when waiting for child process to finish.
+ #[error("Error when waiting for child process to finish")]
+ WaitForChild(#[source] std::io::Error),
+
+ /// Error when reading a file.
+ #[error("Error when reading {0}")]
+ ReadFile(PathBuf, #[source] std::io::Error),
+
+ /// Error when creating a file.
+ #[error("Error when creating {0}")]
+ CreateFile(PathBuf, #[source] std::io::Error),
+
+ /// Error when writing to a file.
+ #[error("Error when writing to {0}")]
+ WriteFile(PathBuf, #[source] std::io::Error),
+
+ /// Error executing Pandoc.
+ #[error("Pandoc failed")]
+ Pandoc(#[source] pandoc::PandocError),
/// Regular expression error
///
/// Subplot uses regular expressions. This is a generic wrapper for
/// any kinds of errors related to that.
- #[error(transparent)]
- RegexError {
- /// The wrapped error.
- #[from]
- source: regex::Error,
- },
+ #[error("Failed to compile regular expression: {0:?}")]
+ Regex(String, #[source] regex::Error),
- /// JSON error
- ///
- /// Subplot parses and generates JSON. This is a generic wrapper
- /// for any kinds of errors related to that.
- #[error(transparent)]
- JsonError {
- /// The wrapped error.
- #[from]
- source: serde_json::Error,
- },
+ /// Error parsing the Pandoc abstract syntax tree as JSON.
+ #[error("Failed to parse document AST as JSON")]
+ AstJson(#[source] serde_json::Error),
- /// YAML error
- ///
- /// Subplot parses YAML. This is a generic wrapper for any kinds
- /// of errors related to that.
- #[error(transparent)]
- YamlError {
- /// The wrapped error.
- #[from]
- source: serde_yaml::Error,
- },
+ /// Error parsing YAML metadata for document.
+ #[error("Failed to parse YAML metadata")]
+ Metadata(#[source] serde_yaml::Error),
/// Abstract syntax tree error.
#[error(transparent)]
@@ -336,9 +324,6 @@ 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.