dctap/
tap_error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use std::{io, result};

use calamine::XlsxError;
use csv::{Position, StringRecord};
use thiserror::Error;

pub type Result<T> = result::Result<T, TapError>;

#[derive(Error, Debug)]
pub enum TapError {
    #[error("Empty node type at line: {}, Record: {}", pos.line(), pos.record())]
    EmptyNodeType { pos: Position },

    #[error("Unexpected node type: {str}. Line: {}, Record: {}", pos.line(), pos.record())]
    UnexpectedNodeType { str: String, pos: Position },

    #[error("Unexpected value constraint type: {value}. Line: {}, Record: {}", pos.line(), pos.record())]
    UnexpectedValueConstraintType { value: String, pos: Position },

    #[error("CSV Error: {err}")]
    CSVError {
        #[from]
        err: csv::Error,
    },

    #[error("Cannot obtain shape id with index {shape_id} from record {record:?}")]
    NoShapeId {
        shape_id: usize,
        record: StringRecord,
    },

    #[error(
        "Value of field {field} is {value} and should be boolean. Line: {}. Record: {}",
        pos.line(),
        pos.record()
    )]
    ShouldBeBoolean {
        field: String,
        value: String,
        pos: Position,
    },

    #[error("Error reading config file from path {path}: {error}")]
    TapConfigFromPathError { path: String, error: io::Error },

    #[error("Error reading config file from path {path}: {error}")]
    TapConfigYamlError {
        path: String,
        error: serde_yml::Error,
    },

    #[error("Reading Excel file from {path}: {error}")]
    ReadingExcelError { path: String, error: io::Error },

    #[error(transparent)]
    XlsxError {
        #[from]
        error: XlsxError,
    },

    #[error("No headers found in Excel file: {path}")]
    NoHeadersExcel { path: String },

    #[error("Cannot open work_book {path}: {error}")]
    OpeningWorkbook { path: String, error: XlsxError },

    #[error("Sheet not found in {path} when looking for first sheet")]
    Sheet0NotFound { path: String },

    #[error("Error obtaining sheet 0 from {path}. Error: {error}")]
    Sheet0Error { path: String, error: XlsxError },

    #[error("Error processing sheet {sheet_name} from {path}. Error: {error}")]
    SheetNameError {
        path: String,
        sheet_name: String,
        error: XlsxError,
    },
}