From be6519d4f2c3d7d033f0f6da976bc267e3573721 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Thu, 29 Sep 2022 13:44:33 -0400 Subject: [PATCH] fix: Add filename to the data generator read file error --- iox_data_generator/src/specification.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/iox_data_generator/src/specification.rs b/iox_data_generator/src/specification.rs index 00ee48488d..5ffa8bafc1 100644 --- a/iox_data_generator/src/specification.rs +++ b/iox_data_generator/src/specification.rs @@ -12,8 +12,13 @@ use tracing::warn; #[allow(missing_docs)] pub enum Error { /// File-related error that may happen while reading a specification - #[snafu(display(r#"Error reading data spec from TOML file: {}"#, source))] + #[snafu(display( + r#"Error reading data spec from TOML file at {}: {}"#, + file_name, + source + ))] ReadFile { + file_name: String, /// Underlying I/O error that caused this problem source: std::io::Error, }, @@ -76,7 +81,7 @@ pub struct DataSpec { impl DataSpec { /// Given a filename, read the file and parse the specification. pub fn from_file(file_name: &str) -> Result { - let spec_toml = fs::read_to_string(file_name).context(ReadFileSnafu)?; + let spec_toml = fs::read_to_string(file_name).context(ReadFileSnafu { file_name })?; Self::from_str(&spec_toml) }