1use crate::create_messages;
18
19use std::{
20 error::Error as ErrorArg,
21 fmt::{Debug, Display},
22};
23
24create_messages!(
25 PackageError,
27 code_mask: 5000i32,
28 code_prefix: "PAK",
29
30 @backtraced
32 failed_to_get_input_file_entry {
33 args: (error: impl ErrorArg),
34 msg: format!("failed to get input file entry: {error}"),
35 help: None,
36 }
37
38 @backtraced
40 failed_to_get_input_file_type {
41 args: (file: impl Debug, error: impl ErrorArg),
42 msg: format!("failed to get input file `{file:?}` type: {error}"),
43 help: None,
44 }
45
46 @backtraced
48 invalid_input_file_type {
49 args: (file: impl Debug, type_: std::fs::FileType),
50 msg: format!("input file `{file:?}` has invalid type: {type_:?}"),
51 help: None,
52 }
53
54 @backtraced
56 failed_to_create_inputs_directory {
57 args: (error: impl ErrorArg),
58 msg: format!("failed creating inputs directory {error}"),
59 help: None,
60 }
61
62 @backtraced
64 failed_to_read_circuit_file {
65 args: (path: impl Debug),
66 msg: format!("Cannot read struct file from the provided file path - {path:?}"),
67 help: None,
68 }
69
70 @backtraced
72 failed_to_read_inputs_directory {
73 args: (error: impl ErrorArg),
74 msg: format!("failed reading inputs directory {error}"),
75 help: None,
76 }
77
78 @backtraced
80 failed_to_read_input_file {
81 args: (path: impl Debug),
82 msg: format!("Cannot read input file from the provided file path - {path:?}"),
83 help: None,
84 }
85
86 @backtraced
88 failed_to_read_snapshot_file {
89 args: (path: impl Debug),
90 msg: format!("Cannot read snapshot file from the provided file path - {path:?}"),
91 help: None,
92 }
93
94 @backtraced
96 failed_to_read_checksum_file {
97 args: (path: impl Debug),
98 msg: format!("Cannot read checksum file from the provided file path - {path:?}"),
99 help: None,
100 }
101
102 @backtraced
104 io_error_circuit_file {
105 args: (error: impl ErrorArg),
106 msg: format!("IO error struct file from the provided file path - {error}"),
107 help: None,
108 }
109
110 @backtraced
112 io_error_checksum_file {
113 args: (error: impl ErrorArg),
114 msg: format!("IO error checksum file from the provided file path - {error}"),
115 help: None,
116 }
117
118 @backtraced
120 io_error_main_file {
121 args: (error: impl ErrorArg),
122 msg: format!("IO error main file from the provided file path - {error}"),
123 help: None,
124 }
125
126 @backtraced
128 failed_to_remove_circuit_file {
129 args: (path: impl Debug),
130 msg: format!("failed removing struct file from the provided file path - {path:?}"),
131 help: None,
132 }
133
134 @backtraced
136 failed_to_remove_checksum_file {
137 args: (path: impl Debug),
138 msg: format!("failed removing checksum file from the provided file path - {path:?}"),
139 help: None,
140 }
141
142 @backtraced
144 failed_to_remove_snapshot_file {
145 args: (path: impl Debug),
146 msg: format!("failed removing snapshot file from the provided file path - {path:?}"),
147 help: None,
148 }
149
150 @backtraced
152 io_error_input_file {
153 args: (error: impl ErrorArg),
154 msg: format!("IO error input file from the provided file path - {error}"),
155 help: None,
156 }
157
158 @backtraced
160 io_error_gitignore_file {
161 args: (error: impl ErrorArg),
162 msg: format!("IO error gitignore file from the provided file path - {error}"),
163 help: None,
164 }
165
166 @backtraced
168 failed_to_create_source_directory {
169 args: (path: impl Display, error: impl ErrorArg),
170 msg: format!("Failed creating source directory at `{path}`: {error}."),
171 help: None,
172 }
173
174 @backtraced
176 failed_to_get_leo_file_entry {
177 args: (error: impl ErrorArg),
178 msg: format!("Failed to get Leo file entry: {error}."),
179 help: None,
180 }
181
182 @backtraced
184 failed_to_get_leo_file_extension {
185 args: (extension: impl Debug),
186 msg: format!("Failed to get Leo file extension: {extension:?}."),
187 help: None,
188 }
189
190 @backtraced
192 invalid_leo_file_extension {
193 args: (file: impl Debug, extension: impl Debug),
194 msg: format!("Source file `{file:?}` has invalid extension: {extension:?}."),
195 help: None,
196 }
197
198 @backtraced
200 failed_to_initialize_package {
201 args: (package: impl Display, path: impl Debug, error: impl Display),
202 msg: format!("Failed to initialize package {package} at {path:?}. Error: {error}"),
203 help: None,
204 }
205
206 @backtraced
208 invalid_package_name {
209 args: (package: impl Display),
210 msg: format!("Invalid project name {package}"),
211 help: None,
212 }
213
214 @backtraced
216 directory_not_found {
217 args: (dirname: impl Display, path: impl Display),
218 msg: format!("The `{dirname}` does not exist at `{path}`."),
219 help: None,
220 }
221
222 @backtraced
224 failed_to_create_directory {
225 args: (dirname: impl Display, error: impl ErrorArg),
226 msg: format!("failed to create directory `{dirname}`, error: {error}."),
227 help: None,
228 }
229
230 @backtraced
232 failed_to_remove_directory {
233 args: (dirname: impl Display, error: impl ErrorArg),
234 msg: format!("failed to remove directory: {dirname}, error: {error}"),
235 help: None,
236 }
237
238 @backtraced
240 failed_to_read_file {
241 args: (path: impl Display, error: impl Display),
242 msg: format!("failed to read file: {path}, error: {error}"),
243 help: None,
244 }
245
246 @backtraced
247 failed_to_get_file_name {
248 args: (),
249 msg: "Failed to get names of Leo files in the `src/` directory.".to_string(),
250 help: Some("Check your `src/` directory for invalid file names.".to_string()),
251 }
252
253 @backtraced
254 failed_to_set_cwd {
255 args: (dir: impl Display, error: impl ErrorArg),
256 msg: format!("Failed to set current working directory to `{dir}`. Error: {error}."),
257 help: None,
258 }
259
260 @backtraced
261 failed_to_open_manifest {
262 args: (error: impl Display),
263 msg: format!("Failed to open manifest file: {error}"),
264 help: Some("Create a package by running `leo new`.".to_string()),
265 }
266
267 @backtraced
268 failed_to_read_manifest {
269 args: (error: impl Display),
270 msg: format!("Failed to read manifest file: {error}"),
271 help: Some("Create a package by running `leo new`.".to_string()),
272 }
273
274 @backtraced
275 failed_to_write_manifest {
276 args: (error: impl Display),
277 msg: format!("Failed to write manifest file: {error}"),
278 help: Some("Create a package by running `leo new`.".to_string()),
279 }
280
281 @backtraced
282 failed_to_create_manifest {
283 args: (error: impl Display),
284 msg: format!("Failed to create manifest file: {error}"),
285 help: Some("Create a package by running `leo new`.".to_string()),
286 }
287
288 @backtraced
289 failed_to_open_aleo_file {
290 args: (error: impl Display),
291 msg: format!("Failed to open Aleo file: {error}"),
292 help: Some("Create a package by running `leo new`.".to_string()),
293 }
294
295 @backtraced
296 failed_to_create_aleo_file {
297 args: (error: impl Display),
298 msg: format!("Failed to create Aleo file: {error}."),
299 help: None,
300 }
301
302 @backtraced
303 failed_to_write_aleo_file {
304 args: (error: impl Display),
305 msg: format!("Failed to write aleo file: {error}."),
306 help: None,
307 }
308
309 @backtraced
310 failed_to_remove_aleo_file {
311 args: (error: impl Display),
312 msg: format!("Failed to remove aleo file: {error}."),
313 help: None,
314 }
315
316 @backtraced
317 empty_source_directory {
318 args: (),
319 msg: "The `src/` directory is empty.".to_string(),
320 help: Some("Add a `main.leo` file to the `src/` directory.".to_string()),
321 }
322
323 @backtraced
324 source_directory_can_contain_only_one_file {
325 args: (directory: impl Display),
326 msg: format!("The `{directory}` source directory can contain only one file which must be named `main.leo`."),
327 help: None,
328 }
329
330 @backtraced
332 io_error_env_file {
333 args: (error: impl ErrorArg),
334 msg: format!("IO error env file from the provided file path - {error}"),
335 help: None,
336 }
337
338 @backtraced
339 failed_to_deserialize_manifest_file {
340 args: (path: impl Display, error: impl ErrorArg),
341 msg: format!("Failed to deserialize `program.json` from the provided file path {path} - {error}"),
342 help: None,
343 }
344
345 @backtraced
346 failed_to_serialize_manifest_file {
347 args: (path: impl Display, error: impl ErrorArg),
348 msg: format!("Failed to update `program.json` from the provided file path {path} - {error}"),
349 help: None,
350 }
351
352 @backtraced
353 failed_to_deserialize_lock_file {
354 args: (error: impl ErrorArg),
355 msg: format!("Failed to deserialize `leo.lock` - {error}"),
356 help: None,
357 }
358
359 @backtraced
360 invalid_lock_file_formatting {
361 args: (),
362 msg: "Invalid `leo.lock` formatting.".to_string(),
363 help: Some("Delete the lock file and rebuild the project".to_string()),
364 }
365
366 @backtraced
367 unimplemented_command {
368 args: (command: impl Display),
369 msg: format!("The `{command}` command is not implemented."),
370 help: None,
371 }
372
373 @backtraced
374 invalid_file_name_dependency {
375 args: (name: impl Display),
376 msg: format!("The dependency program name `{name}` is invalid."),
377 help: Some("Aleo program names must only contain lower case letters, numbers and underscores.".to_string()),
378 }
379
380 @backtraced
381 dependency_not_found {
382 args: (name: impl Display),
383 msg: format!("The dependency program `{name}` was not found among the manifest's dependencies."),
384 help: None,
385 }
386
387 @backtraced
388 conflicting_on_chain_program_name {
389 args: (first: impl Display, second: impl Display),
390 msg: format!("Conflicting program names given to execute on chain: `{first}` and `{second}`."),
391 help: Some("Either set `--local` to execute the local program on chain, or set `--program <PROGRAM>`.".to_string()),
392 }
393
394 @backtraced
395 missing_on_chain_program_name {
396 args: (),
397 msg: "The name of the program to execute on-chain is missing.".to_string(),
398 help: Some("Either set `--local` to execute the local program on chain, or set `--program <PROGRAM>`.".to_string()),
399 }
400
401 @backtraced
402 failed_to_read_manifest_file {
403 args: (path: impl Display, error: impl ErrorArg),
404 msg: format!("Failed to read manifest file from the provided file path {path} - {error}"),
405 help: None,
406 }
407
408 @backtraced
409 insufficient_balance {
410 args: (address: impl Display, balance: impl Display, fee: impl Display),
411 msg: format!("❌ Your public balance of {balance} for {address} is insufficient to pay the base fee of {fee}"),
412 help: None,
413 }
414
415 @backtraced
416 execution_error {
417 args: (error: impl Display),
418 msg: format!("❌ Execution error: {error}"),
419 help: Some("Make sure that you are using the right `--network` options.".to_string()),
420 }
421
422 @backtraced
423 snarkvm_error {
424 args: (error: impl Display),
425 msg: format!("[snarkVM Error] {error}"),
426 help: None,
427 }
428
429 @backtraced
430 failed_to_load_package {
431 args: (path: impl Display),
432 msg: format!("Failed to load leo project at path {path}"),
433 help: Some("Make sure that the path is correct and that the project exists.".to_string()),
434 }
435
436 @backtraced
437 conflicting_dependency {
438 args: (existing: impl Display, new: impl Display),
439 msg: format!("Conflicting dependency. The existing dependency is '{existing}', while the new one is '{new}'."),
440 help: Some("If your project has multiple dependencies on the same program, make sure that they are all network or all local dependencies, with the same editions.".to_string()),
441 }
442
443 @backtraced
444 conflicting_manifest {
445 args: (expected_name: impl Display, manifest_name: impl Display),
446 msg: format!("Expected to find program {expected_name}, but manifest found for program {manifest_name}."),
447 help: None,
448 }
449
450 @backtraced
451 invalid_network_name {
452 args: (name: impl Display),
453 msg: format!("Invalid network name {name} in manifest `program.json`."),
454 help: None,
455 }
456
457 @backtraced
458 failed_path {
459 args: (path: impl Display, err: impl Display),
460 msg: format!("Cannot find path `{path}`: {err}."),
461 help: None,
462 }
463);