1 use std::io::Error as IoError;
2 use thiserror::Error as ThisError;
8 #[derive(ThisError, Debug)]
10 #[error("Not an SPSS system file")]
13 #[error("Invalid magic number {0:?}")]
16 #[error("I/O error ({0})")]
19 #[error("Invalid SAV compression code {0}")]
20 InvalidSavCompression(u32),
22 #[error("Invalid ZSAV compression code {0}")]
23 InvalidZsavCompression(u32),
25 #[error("Variable record at offset {offset:#x} specifies width {width} not in valid range [-1,255).")]
26 BadVariableWidth { offset: u64, width: i32 },
28 #[error("Document record at offset {offset:#x} has document line count ({n}) greater than the maximum number {max}.")]
29 BadDocumentLength { offset: u64, n: u32, max: u32 },
31 #[error("At offset {offset:#x}, Unrecognized record type {rec_type}.")]
32 BadRecordType { offset: u64, rec_type: u32 },
34 #[error("At offset {offset:#x}, variable label code ({code}) is not 0 or 1.")]
35 BadVariableLabelCode { offset: u64, code: u32 },
38 "At offset {offset:#x}, numeric missing value code ({code}) is not -3, -2, 0, 1, 2, or 3."
40 BadNumericMissingValueCode { offset: u64, code: i32 },
42 #[error("At offset {offset:#x}, string missing value code ({code}) is not 0, 1, 2, or 3.")]
43 BadStringMissingValueCode { offset: u64, code: i32 },
45 #[error("At offset {offset:#x}, number of value labels ({n}) is greater than the maximum number {max}.")]
46 BadNumberOfValueLabels { offset: u64, n: u32, max: u32 },
48 #[error("At offset {offset:#x}, number of variables indexes ({n}) is greater than the maximum number ({max}).")]
49 BadNumberOfVarIndexes { offset: u64, n: u32, max: u32 },
51 #[error("At offset {offset:#x}, record type 7 subtype {subtype} is too large with element size {size} and {count} elements.")]
52 ExtensionRecordTooLarge {
59 #[error("Unexpected end of file at offset {offset:#x}, {case_ofs} bytes into a {case_len}-byte case.")]
67 "Unexpected end of file at offset {offset:#x}, {case_ofs} bytes into a compressed case."
69 EofInCompressedCase { offset: u64, case_ofs: u64 },
71 #[error("Data ends at offset {offset:#x}, {case_ofs} bytes into a compressed case.")]
72 PartialCompressedCase { offset: u64, case_ofs: u64 },
74 #[error("At {case_ofs} bytes into compressed case starting at offset {offset:#x}, a string was found where a number was expected.")]
75 CompressedNumberExpected { offset: u64, case_ofs: u64 },
77 #[error("At {case_ofs} bytes into compressed case starting at offset {offset:#x}, a number was found where a string was expected.")]
78 CompressedStringExpected { offset: u64, case_ofs: u64 },
80 #[error("Block count {n_blocks} in ZLIB trailer at offset {offset:#x} differs from expected block count {expected_n_blocks} calculated from trailer length {ztrailer_len}.")]
81 BadZlibTrailerNBlocks {
84 expected_n_blocks: u64,