diff --git a/src/csv_animation.rs b/src/csv_animation.rs index 5b1d363..11fa24b 100644 --- a/src/csv_animation.rs +++ b/src/csv_animation.rs @@ -26,7 +26,21 @@ pub enum CSVParseError { impl std::fmt::Display for CSVParseError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&format!("{self:?}")) + match self { + CSVParseError::NoData => f.write_str("Empty CSV File"), + CSVParseError::InvalidCSV(e) => f.write_str(&format!("Invalid CSV: {e}")), + CSVParseError::NoMorphs => f.write_str("No Morphs Available in the CSV File"), + CSVParseError::MisssingKnownHeaders => { + f.write_str("No Timestamp or Morph Count Headers") + } + CSVParseError::NoFrames => f.write_str("The CSV has 0 frames"), + CSVParseError::TimecodeParseError(e) => { + f.write_str(&format!("Couldn't parse a timecode in the CSV: {e}")) + } + CSVParseError::MorphParseError(e) => f.write_str(&format!( + "Couldn't parse a morph in the CSV - is it not a floating point number?: {e}" + )), + } } } diff --git a/src/csv_frame.rs b/src/csv_frame.rs index a9ab4e2..030bf0f 100644 --- a/src/csv_frame.rs +++ b/src/csv_frame.rs @@ -23,7 +23,15 @@ pub enum TimestampParseError { impl std::fmt::Display for TimestampParseError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&format!("{self:?}")) + match self { + TimestampParseError::EmptyTimestamp => f.write_str("The timestamp is an empty string"), + TimestampParseError::TooManySegments => { + f.write_str("There are too many segments in the timestamp") + } + TimestampParseError::NumberParseError(e, s) => f.write_str(&format!( + "Couldn't parse one of the segments - is {s} a number?: {e}" + )), + } } } diff --git a/src/lib.rs b/src/lib.rs index bfd7958..b794cff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,29 @@ pub enum CSVAnimationLoaderError { impl std::fmt::Display for CSVAnimationLoaderError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&format!("{self:?}")) + match self { + CSVAnimationLoaderError::Io(e) => { + f.write_str(&format!("Error accessing the CSV animation files: {e}")) + } + CSVAnimationLoaderError::CSVParseError(e) => { + f.write_str(&format!("Failed to parse the CSV file: {e}")) + } + CSVAnimationLoaderError::ClipInfoParseError(e) => { + f.write_str(&format!("Couldn't parse Clip Info file: {e}")) + } + CSVAnimationLoaderError::CSVReadBytesError(e) => { + f.write_str(&format!("Error while reading the CSV file: {e}")) + } + CSVAnimationLoaderError::CSVStringError(e) => f.write_str(&format!( + "Couldn't process CSV file - is it encoded as Utf8? {e}" + )), + CSVAnimationLoaderError::MappingReadBytesError(e) => { + f.write_str(&format!("Couldn't read mapping file: {e}")) + } + CSVAnimationLoaderError::MappingParseError(e) => { + f.write_str(&format!("Failed to parse mapping file: {e}")) + } + } } }