• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 6034126612

31 Aug 2023 07:03AM UTC coverage: 77.119%. First build
6034126612

Pull #1945

github

Jesse-Bakker
Write dozer.lock
Pull Request #1945: Write dozer.lock

86 of 86 new or added lines in 9 files covered. (100.0%)

49169 of 63757 relevant lines covered (77.12%)

69984.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/dozer-cli/src/errors.rs
1
#![allow(clippy::enum_variant_names)]
2

3
use glob::{GlobError, PatternError};
4
use std::io;
5
use std::path::PathBuf;
6
use tonic::Code::NotFound;
7

8
use crate::{
9
    errors::CloudError::{ApplicationNotFound, CloudServiceError},
10
    live::LiveError,
11
};
12
use dozer_api::{
13
    errors::{ApiInitError, AuthError, GenerationError, GrpcError},
14
    rest::DOZER_SERVER_NAME_HEADER,
15
};
16
use dozer_cache::dozer_log::storage;
17
use dozer_cache::errors::CacheError;
18
use dozer_core::errors::ExecutionError;
19
use dozer_ingestion::errors::ConnectorError;
20
use dozer_sql::pipeline::errors::PipelineError;
21
use dozer_types::thiserror::Error;
22
use dozer_types::{errors::internal::BoxedError, serde_json};
23
use dozer_types::{serde_yaml, thiserror};
24

25
use crate::pipeline::connector_source::ConnectorSourceFactoryError;
26

27
pub fn map_tonic_error(e: tonic::Status) -> CloudError {
×
28
    if e.code() == NotFound && e.message() == "Failed to find app" {
×
29
        ApplicationNotFound
×
30
    } else {
31
        CloudServiceError(e)
×
32
    }
33
}
×
34

35
#[derive(Error, Debug)]
×
36
pub enum OrchestrationError {
37
    #[error("Failed to write config yaml: {0:?}")]
38
    FailedToWriteConfigYaml(#[source] serde_yaml::Error),
39
    #[error("File system error {0:?}: {1}")]
40
    FileSystem(PathBuf, std::io::Error),
41
    #[error("Failed to find any build")]
42
    NoBuildFound,
43
    #[error("Failed to create log: {0}")]
44
    CreateLog(#[from] dozer_cache::dozer_log::replication::Error),
45
    #[error("Failed to login: {0}")]
46
    CloudLoginFailed(#[from] CloudLoginError),
47
    #[error("Credential Error: {0}")]
48
    CredentialError(#[from] CloudCredentialError),
49
    #[error("Failed to build: {0}")]
50
    BuildFailed(#[from] BuildError),
51
    #[error("Failed to generate token: {0}")]
52
    GenerateTokenFailed(#[source] AuthError),
53
    #[error("Missing api config or security input")]
54
    MissingSecurityConfig,
55
    #[error("Cloud service error: {0}")]
56
    CloudError(#[from] CloudError),
57
    #[error("Failed to initialize api server: {0}")]
58
    ApiInitFailed(#[from] ApiInitError),
59
    #[error("Failed to server REST API: {0}")]
60
    RestServeFailed(#[source] std::io::Error),
61
    #[error("Failed to server gRPC API: {0:?}")]
62
    GrpcServeFailed(#[source] tonic::transport::Error),
63
    #[error("Failed to initialize internal server: {0}")]
64
    InternalServerFailed(#[source] GrpcError),
65
    #[error("{0}: Failed to initialize cache. Have you run `dozer build`?")]
66
    CacheInitFailed(#[source] CacheError),
67
    #[error("Failed to build cache {0} from log: {1}")]
68
    CacheBuildFailed(String, #[source] CacheError),
69
    #[error("Cache {0} has reached its maximum size. Try to increase `cache_max_map_size` in the config.")]
70
    CacheFull(String),
71
    #[error("Internal thread panic: {0}")]
72
    JoinError(#[source] tokio::task::JoinError),
73
    #[error("Connector source factory error: {0}")]
74
    ConnectorSourceFactory(#[from] ConnectorSourceFactoryError),
75
    #[error(transparent)]
76
    ExecutionError(#[from] ExecutionError),
77
    #[error(transparent)]
78
    ConnectorError(#[from] ConnectorError),
79
    #[error(transparent)]
80
    PipelineError(#[from] PipelineError),
81
    #[error(transparent)]
82
    CliError(#[from] CliError),
83
    #[error("table_name: {0:?} not found in any of the connections")]
84
    SourceValidationError(String),
85
    #[error("connection: {0:?} not found")]
86
    ConnectionNotFound(String),
87
    #[error("Pipeline validation failed")]
88
    PipelineValidationError,
89
    #[error("Table name specified in endpoint not found: {0:?}")]
90
    EndpointTableNotFound(String),
91
    #[error("Duplicate table name found: {0:?}")]
92
    DuplicateTable(String),
93
    #[error("No endpoints initialized in the config provided")]
94
    EmptyEndpoints,
95
    #[error(transparent)]
96
    CloudContextError(#[from] CloudContextError),
97
    #[error("Failed to read organisation name. Error: {0}")]
98
    FailedToReadOrganisationName(#[source] io::Error),
99
    #[error(transparent)]
100
    LiveError(#[from] LiveError),
101
}
102

103
#[derive(Error, Debug)]
×
104
pub enum CliError {
105
    #[error("Configuration file path not provided")]
106
    ConfigurationFilePathNotProvided,
107
    #[error("Can't find the configuration file(s) at: {0:?}")]
108
    FailedToFindConfigurationFiles(String),
109
    #[error("Unknown Command: {0:?}")]
110
    UnknownCommand(String),
111
    #[error("Failed to parse dozer config: {0:?}")]
112
    FailedToParseYaml(#[source] BoxedError),
113
    #[error("Failed to validate dozer config: {0:?}")]
114
    FailedToParseValidateYaml(#[source] BoxedError),
115
    #[error("Failed to read line: {0}")]
116
    ReadlineError(#[from] rustyline::error::ReadlineError),
117
    #[error("File system error {0:?}: {1}")]
118
    FileSystem(PathBuf, #[source] std::io::Error),
119
    #[error("Failed to create tokio runtime: {0}")]
120
    FailedToCreateTokioRuntime(#[source] std::io::Error),
121
    #[error("Reqwest error: {0}")]
122
    Reqwest(#[from] reqwest::Error),
123
    #[error(transparent)]
124
    ConfigCombineError(#[from] ConfigCombineError),
125
    #[error("Failed to serialize config to json: {0}")]
126
    SerializeConfigToJson(#[source] serde_json::Error),
127
    #[error("Missing config options to be overridden: {0}")]
128
    MissingConfigOverride(String),
129
    #[error("Failed to deserialize config from json: {0}")]
130
    DeserializeConfigFromJson(#[source] serde_json::Error),
131
    // Generic IO error
132
    #[error(transparent)]
133
    Io(#[from] std::io::Error),
×
134
}
135

136
#[derive(Error, Debug)]
×
137
pub enum CloudError {
138
    #[error("Connection failed. Error: {0:?}")]
139
    ConnectionToCloudServiceError(#[from] tonic::transport::Error),
140

141
    #[error("Cloud service returned error: {0:?}")]
142
    CloudServiceError(#[from] tonic::Status),
143

144
    #[error("GRPC request failed, error: {} (GRPC status {})", .0.message(), .0.code())]
145
    GRPCCallError(#[source] tonic::Status),
146

147
    #[error(transparent)]
148
    CloudCredentialError(#[from] CloudCredentialError),
149

150
    #[error("Reqwest error: {0}")]
151
    Reqwest(#[from] reqwest::Error),
152

153
    #[error("Response header {DOZER_SERVER_NAME_HEADER} is missing")]
154
    MissingResponseHeader,
155

156
    #[error(transparent)]
157
    CloudContextError(#[from] CloudContextError),
158

159
    #[error(transparent)]
160
    ConfigCombineError(#[from] ConfigCombineError),
161

162
    #[error("Application not found")]
163
    ApplicationNotFound,
×
164
}
×
165

166
#[derive(Debug, Error)]
×
167
pub enum ConfigCombineError {
×
168
    #[error("Failed to parse yaml file {0}: {1}")]
169
    ParseYaml(String, #[source] serde_yaml::Error),
170

171
    #[error("Cannot merge yaml value {from:?} to {to:?}")]
172
    CannotMerge {
173
        from: serde_yaml::Value,
174
        to: serde_yaml::Value,
175
    },
176

177
    #[error("Failed to parse config: {0}")]
178
    ParseConfig(#[source] serde_yaml::Error),
179

180
    #[error("Cannot read configuration: {0:?}")]
181
    CannotReadConfig(PathBuf, #[source] std::io::Error),
182

183
    #[error("Wrong pattern of config files read glob: {0}")]
184
    WrongPatternOfConfigFilesGlob(#[from] PatternError),
185

186
    #[error("Cannot read file: {0}")]
187
    CannotReadFile(#[from] GlobError),
188

189
    #[error("Cannot serialize config to string: {0}")]
190
    CannotSerializeToString(#[source] serde_yaml::Error),
191

192
    #[error("SQL is not a string type")]
193
    SqlIsNotStringType,
×
194
}
×
195

196
#[derive(Debug, Error)]
×
197
pub enum BuildError {
×
198
    #[error("Endpoint {0} not found in DAG")]
199
    MissingEndpoint(String),
200
    #[error("Connection {0} found in DAG but not in config")]
201
    MissingConnection(String),
202
    #[error("Got mismatching primary key for `{endpoint_name}`. Expected: `{expected:?}`, got: `{actual:?}`")]
203
    MismatchPrimaryKey {
204
        endpoint_name: String,
205
        expected: Vec<String>,
206
        actual: Vec<String>,
207
    },
208
    #[error("Field not found at position {0}")]
209
    FieldNotFound(String),
210
    #[error("File system error {0:?}: {1}")]
211
    FileSystem(PathBuf, std::io::Error),
212
    #[error(
213
        "Failed to load existing contract: {0}. You have to run a force build: `dozer build --force`."
214
    )]
215
    FailedToLoadExistingContract(#[source] serde_json::Error),
216
    #[error("Serde json error: {0}")]
217
    SerdeJson(#[source] serde_json::Error),
218
    #[error("Failed to generate proto files: {0:?}")]
219
    FailedToGenerateProtoFiles(#[from] GenerationError),
220
    #[error("Storage error: {0}")]
221
    Storage(#[from] storage::Error),
×
222
}
×
223

224
#[derive(Debug, Error)]
×
225
pub enum CloudLoginError {
×
226
    #[error("Tonic error: {0}")]
227
    TonicError(#[from] tonic::Status),
228

229
    #[error("Transport error: {0}")]
230
    Transport(#[from] tonic::transport::Error),
231

232
    #[error("HttpRequest error: {0}")]
233
    HttpRequestError(#[from] reqwest::Error),
234

235
    #[error(transparent)]
236
    SerializationError(#[from] dozer_types::serde_json::Error),
237

238
    #[error("Failed to read input: {0}")]
239
    InputError(#[from] std::io::Error),
240

241
    #[error(transparent)]
242
    CloudCredentialError(#[from] CloudCredentialError),
243

244
    #[error("Organisation not found")]
245
    OrganisationNotFound,
×
246
}
×
247

248
#[derive(Debug, Error)]
×
249
pub enum CloudCredentialError {
×
250
    #[error(transparent)]
251
    SerializationError(#[from] dozer_types::serde_yaml::Error),
252

253
    #[error(transparent)]
254
    JsonSerializationError(#[from] dozer_types::serde_json::Error),
255
    #[error("Failed to create home directory: {0}")]
256
    FailedToCreateDirectory(#[from] std::io::Error),
257

258
    #[error("HttpRequest error: {0}")]
259
    HttpRequestError(#[from] reqwest::Error),
260

261
    #[error("Missing credentials.yaml file - Please try to login again")]
262
    MissingCredentialFile,
263
    #[error("There's no profile with given name - Please try to login again")]
264
    MissingProfile,
×
265
}
×
266

267
#[derive(Debug, Error)]
×
268
pub enum CloudContextError {
×
269
    #[error("Failed to create access directory: {0}")]
270
    FailedToAccessDirectory(#[from] std::io::Error),
271

272
    #[error("Failed to get current directory path")]
273
    FailedToGetDirectoryPath,
274

275
    #[error("App id not found in configuration. You need to run \"deploy\" or \"set-app\" first")]
276
    AppIdNotFound,
277
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc