1use std::io;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum WdlError {
9 #[error("I/O error: {0}")]
11 Io(#[from] io::Error),
12
13 #[error("Invalid magic value: expected '{expected}', found '{found}'")]
15 InvalidMagic {
16 expected: String,
18 found: String,
20 },
21
22 #[error("Unsupported WDL version: {0}")]
24 UnsupportedVersion(u32),
25
26 #[error("Parse error: {0}")]
28 ParseError(String),
29
30 #[error("Validation error: {0}")]
32 ValidationError(String),
33
34 #[error("Version conversion error: {0}")]
36 VersionConversionError(String),
37
38 #[error("Unexpected end of file")]
40 UnexpectedEof,
41
42 #[error("Unexpected chunk type: {0}")]
44 UnexpectedChunk(String),
45}
46
47pub type Result<T> = std::result::Result<T, WdlError>;
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_error_display() {
56 let error = WdlError::ParseError("Test error".to_string());
57 assert_eq!(format!("{error}"), "Parse error: Test error");
58
59 let error = WdlError::InvalidMagic {
60 expected: "MVER".to_string(),
61 found: "ABCD".to_string(),
62 };
63 assert_eq!(
64 format!("{error}"),
65 "Invalid magic value: expected 'MVER', found 'ABCD'"
66 );
67 }
68}