#[error("Ignoring long string value label for numeric variable {0}.")]
LongStringValueLabelNumericVariable(Identifier),
+ #[error("Invalid variable name {0} in variable attribute record.")]
+ UnknownAttributeVariableName(Identifier),
+
#[error("Invalid attribute name. {0}")]
InvalidAttributeName(IdError),
#[error("Invalid short name in long variable name record. {0}")]
InvalidShortName(IdError),
+ #[error("Unknown short name {0} in long variable name record.")]
+ UnknownShortName(Identifier),
+
#[error("Invalid name in long variable name record. {0}")]
InvalidLongName(IdError),
#[error("Invalid variable name in very long string record. {0}")]
InvalidLongStringName(IdError),
+ #[error("Very long string entry for unknown variable {0}.")]
+ UnknownVeryLongString(Identifier),
+
#[error("Variable with short name {short_name} listed in very long string record with width {width}, which requires only one segment.")]
ShortVeryLongString { short_name: Identifier, width: u16 },
#[error("Long string missing values record says variable {name} has {count} missing values, but only 1 to 3 missing values are allowed.")]
LongStringMissingValueInvalidCount { name: Identifier, count: usize },
+ #[error("Long string missing values for variable {0} are too wide.")]
+ MissingValuesTooWide(Identifier),
+
#[error("Unknown extension record with subtype {subtype} at offset {offset:#x}, consisting of {count} {size}-byte units. Please feel free to report this as a bug.")]
UnknownExtensionRecord {
offset: u64,
variable: Identifier,
},
- #[error("Details TBD (cooked)")]
- TBD,
+ #[error(
+ "Dictionary has {expected} variables but {actual} variable display entries are present."
+ )]
+ WrongNumberOfVarDisplay { expected: usize, actual: usize },
}
#[derive(Clone, Debug)]
}
if let Some(display) = &self.var_display {
- for (index, display) in display.0.iter().enumerate() {
- if let Some(variable) = dictionary.variables.get_index_mut2(index) {
- if let Some(width) = display.width {
- variable.display_width = width;
- }
- if let Some(alignment) = display.alignment {
- variable.alignment = alignment;
- }
- if let Some(measure) = display.measure {
- variable.measure = Some(measure);
- }
- } else {
- warn(dbg!(Error::TBD));
+ if display.0.len() != dictionary.variables.len() {
+ warn(Error::WrongNumberOfVarDisplay {
+ expected: dictionary.variables.len(),
+ actual: display.0.len(),
+ });
+ }
+ for (display, index) in display.0.iter().zip(0..dictionary.variables.len()) {
+ let variable = dictionary.variables.get_index_mut2(index).unwrap();
+ if let Some(width) = display.width {
+ variable.display_width = width;
+ }
+ if let Some(alignment) = display.alignment {
+ variable.alignment = alignment;
+ }
+ if let Some(measure) = display.measure {
+ variable.measure = Some(measure);
}
}
}
.flat_map(|record| record.0.into_iter())
{
let Some(index) = dictionary.variables.get_index_of(&record.short_name.0) else {
- warn(dbg!(Error::TBD));
+ warn(Error::UnknownVeryLongString(record.short_name.clone()));
continue;
};
let width = VarWidth::String(record.length);
let n_segments = width.n_segments();
if n_segments == 1 {
- warn(dbg!(Error::ShortVeryLongString {
+ warn(Error::ShortVeryLongString {
short_name: record.short_name.clone(),
width: record.length
- }));
+ });
continue;
}
if index + n_segments > dictionary.variables.len() {
- warn(dbg!(Error::VeryLongStringOverflow {
+ warn(Error::VeryLongStringOverflow {
short_name: record.short_name.clone(),
width: record.length,
index,
n_segments,
len: dictionary.variables.len()
- }));
+ });
continue;
}
let mut short_names = Vec::with_capacity(n_segments);
.unwrap()
.short_names = vec![short_name];
} else {
- warn(dbg!(Error::TBD));
+ warn(Error::UnknownShortName(short_name.clone()));
}
}
}
{
variable.attributes.append(&mut attr_set.attributes);
} else {
- warn(dbg!(Error::TBD));
+ warn(Error::UnknownAttributeVariableName(
+ attr_set.long_var_name.clone(),
+ ));
}
}
.collect::<Vec<_>>();
match MissingValues::new(values, None) {
Ok(missing_values) => variable.missing_values = missing_values,
- Err(MissingValuesError::TooWide) => warn(dbg!(Error::TBD)),
+ Err(MissingValuesError::TooWide) => {
+ warn(Error::MissingValuesTooWide(record.var_name.clone()))
+ }
Err(MissingValuesError::TooMany) | Err(MissingValuesError::MixedTypes) => {
unreachable!()
}
#[error("Attribute for {name}[{}] missing quotations.", index + 1)]
AttributeMissingQuotes { name: Identifier, index: usize },
+ #[error("Variable attribute missing `:`.")]
+ VariableAttributeMissingColon,
+
#[error("Duplicate attributes for variable {variable}: {}.", attributes.iter().join(", "))]
DuplicateVariableAttributes {
variable: Identifier,
#[error("Duplicate dataset attributes with names: {}.", attributes.iter().join(", "))]
DuplicateFileAttributes { attributes: Vec<Identifier> },
+ #[error("File attributes record contains trailing garbage.")]
+ FileAttributesTrailingGarbage,
+
#[error("Compression bias is {0} instead of the usual values of 0 or 100.")]
UnexpectedBias(f64),
actual: u32,
max_expected: u32,
},
-
- #[error("Details TBD (raw)")]
- TBD,
}
impl From<IoError> for WarningDetails {