1use calamine::XlsxError;
2use csv::{Position, StringRecord};
3use std::{io, result};
4use thiserror::Error;
5
6pub type Result<T> = result::Result<T, TapError>;
7
8#[derive(Error, Debug)]
9pub enum TapError {
10 #[error("Empty node type at line: {}, Record: {}", pos.line(), pos.record())]
11 EmptyNodeType { pos: Position },
12
13 #[error("Unexpected node type: {str}. Line: {}, Record: {}", pos.line(), pos.record())]
14 UnexpectedNodeType { str: String, pos: Position },
15
16 #[error("Unexpected value constraint type: {value}. Line: {}, Record: {}", pos.line(), pos.record())]
17 UnexpectedValueConstraintType { value: String, pos: Position },
18
19 #[error("CSV Error: {err}")]
20 CSVError {
21 #[from]
22 err: csv::Error,
23 },
24
25 #[error("Cannot obtain shape id with index {shape_id} from record {record:?}")]
26 NoShapeId { shape_id: usize, record: StringRecord },
27
28 #[error(
29 "Value of field {field} is {value} and should be boolean. Line: {}. Record: {}",
30 pos.line(),
31 pos.record()
32 )]
33 ShouldBeBoolean {
34 field: String,
35 value: String,
36 pos: Position,
37 },
38
39 #[error("Error reading config file from path {path}: {error}")]
40 TapConfigFromPathError { path: String, error: io::Error },
41
42 #[error("Error reading config file from path {path}: {error}")]
43 TapConfigTomlError { path: String, error: toml::de::Error },
44
45 #[error("Reading Excel file from {path}: {error}")]
46 ReadingExcelError { path: String, error: io::Error },
47
48 #[error("No headers found in Excel file: {path}")]
54 NoHeadersExcel { path: String },
55
56 #[error("Cannot open work_book {path}: {error}")]
57 OpeningWorkbook { path: String, error: XlsxError },
58 #[error("Sheet not found in {path} when looking for first sheet")]
59 Sheet0NotFound { path: String },
60 #[error("Error obtaining sheet 0 from {path}. Error: {error}")]
61 Sheet0Error { path: String, error: XlsxError },
62
63 #[error("Error processing sheet {sheet_name} from {path}. Error: {error}")]
64 SheetNameError {
65 path: String,
66 sheet_name: String,
67 error: XlsxError,
68 },
69}