1 use std::io::Error as IoError;
2 use thiserror::Error as ThisError;
10 #[derive(ThisError, Debug)]
12 #[error("Not an SPSS system file")]
15 #[error("Invalid magic number {0:?}")]
18 #[error("I/O error ({0})")]
21 #[error("Invalid SAV compression code {0}")]
22 InvalidSavCompression(u32),
24 #[error("Invalid ZSAV compression code {0}")]
25 InvalidZsavCompression(u32),
27 #[error("Variable record at offset {offset:#x} specifies width {width} not in valid range [-1,255).")]
28 BadVariableWidth { offset: u64, width: i32 },
30 #[error("Document record at offset {offset:#x} has document line count ({n}) greater than the maximum number {max}.")]
31 BadDocumentLength { offset: u64, n: u32, max: u32 },
33 #[error("At offset {offset:#x}, unrecognized record type {rec_type}.")]
34 BadRecordType { offset: u64, rec_type: u32 },
36 #[error("At offset {offset:#x}, variable label code ({code}) is not 0 or 1.")]
37 BadVariableLabelCode { offset: u64, code: u32 },
40 "At offset {offset:#x}, numeric missing value code ({code}) is not -3, -2, 0, 1, 2, or 3."
42 BadNumericMissingValueCode { offset: u64, code: i32 },
44 #[error("At offset {offset:#x}, string missing value code ({code}) is not 0, 1, 2, or 3.")]
45 BadStringMissingValueCode { offset: u64, code: i32 },
47 #[error("At offset {offset:#x}, number of value labels ({n}) is greater than the maximum number {max}.")]
48 BadNumberOfValueLabels { offset: u64, n: u32, max: u32 },
50 #[error("At offset {offset:#x}, number of variables indexes ({n}) is greater than the maximum number ({max}).")]
51 BadNumberOfVarIndexes { offset: u64, n: u32, max: u32 },
53 #[error("At offset {offset:#x}, record type 7 subtype {subtype} is too large with element size {size} and {count} elements.")]
54 ExtensionRecordTooLarge {
61 #[error("Unexpected end of file at offset {offset:#x}, {case_ofs} bytes into a {case_len}-byte case.")]
69 "Unexpected end of file at offset {offset:#x}, {case_ofs} bytes into a compressed case."
71 EofInCompressedCase { offset: u64, case_ofs: u64 },
73 #[error("Data ends at offset {offset:#x}, {case_ofs} bytes into a compressed case.")]
74 PartialCompressedCase { offset: u64, case_ofs: u64 },
76 #[error("At {case_ofs} bytes into compressed case starting at offset {offset:#x}, a string was found where a number was expected.")]
77 CompressedNumberExpected { offset: u64, case_ofs: u64 },
79 #[error("At {case_ofs} bytes into compressed case starting at offset {offset:#x}, a number was found where a string was expected.")]
80 CompressedStringExpected { offset: u64, case_ofs: u64 },
82 #[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}.")]
83 BadZlibTrailerNBlocks {
86 expected_n_blocks: u64,
90 #[error("At offset {offset:#x}, {record} has bad size {size} bytes instead of the expected {expected_size}.")]
91 BadRecordSize { offset: u64, record: String, size: u32, expected_size: u32 },
93 #[error("At offset {offset:#x}, {record} has bad count {count} instead of the expected {expected_count}.")]
94 BadRecordCount { offset: u64, record: String, count: u32, expected_count: u32 },