use std::io;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum WdlError {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("Invalid magic value: expected '{expected}', found '{found}'")]
InvalidMagic {
expected: String,
found: String,
},
#[error("Unsupported WDL version: {0}")]
UnsupportedVersion(u32),
#[error("Parse error: {0}")]
ParseError(String),
#[error("Validation error: {0}")]
ValidationError(String),
#[error("Version conversion error: {0}")]
VersionConversionError(String),
#[error("Unexpected end of file")]
UnexpectedEof,
#[error("Unexpected chunk type: {0}")]
UnexpectedChunk(String),
}
pub type Result<T> = std::result::Result<T, WdlError>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_error_display() {
let error = WdlError::ParseError("Test error".to_string());
assert_eq!(format!("{error}"), "Parse error: Test error");
let error = WdlError::InvalidMagic {
expected: "MVER".to_string(),
found: "ABCD".to_string(),
};
assert_eq!(
format!("{error}"),
"Invalid magic value: expected 'MVER', found 'ABCD'"
);
}
}