-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherrors.rs
More file actions
146 lines (100 loc) · 4.35 KB
/
errors.rs
File metadata and controls
146 lines (100 loc) · 4.35 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! This file contains custom errors for the codelist library
use std::io;
use csv;
use regex;
use serde_json;
/// Enum to represent the different types of errors that can occur in the
/// codelist library
#[derive(Debug, thiserror::Error, thiserror_ext::Construct)]
pub enum CodeListError {
#[error("Invalid codelist type: {name}")]
InvalidCodeListType { name: String },
#[error("Entry not found: {code}")]
EntryNotFound { code: String },
#[error("Invalid file path: {msg}")]
InvalidFilePath { msg: String },
#[error("Invalid input: {msg}")]
InvalidInput { msg: String },
#[error("Invalid code field: {msg}")]
InvalidCodeField { msg: String },
#[error("Invalid term field: {msg}")]
InvalidTermField { msg: String },
#[error("Empty code: {msg}")]
EmptyCode { msg: String },
#[error("Column index out of bounds: {msg}")]
ColumnIndexOutOfBounds { msg: String },
#[error("Invalid code type: {msg}")]
InvalidCodeType { msg: String },
#[error("Invalid term type: {msg}")]
InvalidTermType { msg: String },
#[error("Comment for entry with code {code} already exists. {msg}.")]
CodeEntryCommentAlreadyExists { code: String, msg: String },
#[error("Term for entry with code {code} already exists. {msg}.")]
CodeEntryTermAlreadyExists { code: String, msg: String },
#[error("Comment for entry with code {code} does not exist. {msg}.")]
CodeEntryCommentDoesNotExist { code: String, msg: String },
#[error("Term for entry with code {code} does not exist. {msg}.")]
CodeEntryTermDoesNotExist { code: String, msg: String },
#[error("Contributor {contributor} not found")]
ContributorNotFound { contributor: String },
#[error("Invalid metadata source: {source_string}")]
InvalidMetadataSource { source_string: String },
#[error("Purpose already exists: {msg}")]
PurposeAlreadyExists { msg: String },
#[error("Purpose does not exist: {msg}")]
PurposeDoesNotExist { msg: String },
#[error("Target audience already exists: {msg}")]
TargetAudienceAlreadyExists { msg: String },
#[error("Target audience does not exist: {msg}")]
TargetAudienceDoesNotExist { msg: String },
#[error("Use context already exists: {msg}")]
UseContextAlreadyExists { msg: String },
#[error("Use context does not exist: {msg}")]
UseContextDoesNotExist { msg: String },
#[error("Reviewer already exists: {msg}")]
ReviewerAlreadyExists { msg: String },
#[error("Reviewer does not exist: {msg}")]
ReviewerDoesNotExist { msg: String },
#[error("Review date already exists: {msg}")]
ReviewDateAlreadyExists { msg: String },
#[error("Review date does not exist: {msg}")]
ReviewDateDoesNotExist { msg: String },
#[error("Status already exists: {msg}")]
StatusAlreadyExists { msg: String },
#[error("Status does not exist: {msg}")]
StatusDoesNotExist { msg: String },
#[error("Validation notes already exist: {msg}")]
ValidationNotesAlreadyExist { msg: String },
#[error("Validation notes do not exist: {msg}")]
ValidationNotesDoNotExist { msg: String },
#[error("Review date is none.")]
ReviewDateIsNone,
#[error("Tag does not exist: {msg}")]
TagDoesNotExist { msg: String },
#[error("Tag already exists: {msg}")]
TagAlreadyExists { msg: String },
#[error("Usage does not exist: {msg}")]
UsageDoesNotExist { msg: String },
#[error("License already exists: {msg}")]
LicenseAlreadyExists { msg: String },
#[error("License does not exist: {msg}")]
LicenseDoesNotExist { msg: String },
#[error("JSON error: {0}")]
#[construct(skip)]
JSONError(#[from] serde_json::Error),
#[error("IO error: {0}")]
#[construct(skip)]
IOError(#[from] io::Error),
#[error("CSV error: {0}")]
#[construct(skip)]
CSVError(#[from] csv::Error),
#[error("{codelist_type} cannot be truncated to 3 digits.")]
CodeListNotTruncatable { codelist_type: String },
#[error("{term_management} is not known. Valid values are 'first', 'drop_term'")]
TermManagementNotKnown { term_management: String },
#[error("{codelist_type} cannot be transformed by having X added to the end of it")]
CodeListNotXAddable { codelist_type: String },
#[error("Invalid custom regex pattern: {0}")]
#[construct(skip)]
InvalidRegexPattern(#[from] regex::Error),
}