summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fddc1fb..f1e15cb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -87,8 +87,18 @@ impl ReferenceEntry
let function_ref_content = function_file.contents();
let mut parser = Parser::new(function_ref_content);
-
- let root_elements = parser.parse()?;
+ let root_elements =
+ parser
+ .parse()
+ .map_err(|err| ReferenceEntryError::ParsingFailed {
+ source: err,
+ entry_name: function_file
+ .path()
+ .file_stem()
+ .unwrap_or_else(|| OsStr::new("(unknown)"))
+ .to_string_lossy()
+ .to_string(),
+ })?;
ReferenceEntry::from_elements(&root_elements).map_err(|err| {
ReferenceEntryError::Invalid {
@@ -189,8 +199,16 @@ pub enum ReferenceEntryError
},
/// Parsing failed.
- #[error("Parsing failed")]
- ParsingFailed(#[from] ParserError),
+ #[error("Failed to parse reference entry '{entry_name}'")]
+ ParsingFailed
+ {
+ /// Source error.
+ #[source]
+ source: ParserError,
+
+ /// Name of the reference entry that couldn't be parsed.
+ entry_name: String,
+ },
}
/// Error for when a reference entry is invalid.