1use crate::create_messages;
18use std::{
19 error::Error as ErrorArg,
20 fmt::{Debug, Display},
21};
22
23create_messages!(
24 UtilError,
26 code_mask: 10000i32,
27 code_prefix: "UTL",
28
29 @backtraced
30 util_file_io_error {
31 args: (msg: impl Display, err: impl ErrorArg),
32 msg: format!("File system io error: {msg}. Error: {err}"),
33 help: None,
34 }
35
36 @formatted
37 toml_serizalization_error {
38 args: (error: impl ErrorArg),
39 msg: format!("TOML serialization error: {error}"),
40 help: None,
41 }
42
43 @formatted
44 json_serialization_error {
45 args: (error: impl ErrorArg),
46 msg: format!("JSON serialization error: {error}"),
47 help: None,
48 }
49
50 @backtraced
51 snarkvm_parsing_error {
52 args: (name: impl Display),
53 msg: format!("Failed to parse the source file for `{name}.aleo` into a valid Aleo program."),
54 help: None,
55 }
56
57 @backtraced
58 circular_dependency_error {
59 args: (),
60 msg: "Circular dependency detected".to_string(),
61 help: None,
62 }
63
64 @backtraced
65 network_error {
66 args: (url: impl Display, status: impl Display),
67 msg: format!("Failed network request to {url}. Status: {status}"),
68 help: Some("Make sure that you are using the correct `--network` and `--endpoint` options.".to_string()),
69 }
70
71 @formatted
72 duplicate_dependency_name_error {
73 args: (dependency: impl Display),
74 msg: format!("Duplicate dependency found: {dependency}"),
75 help: None,
76 }
77
78 @backtraced
79 reqwest_error {
80 args: (error: impl Display),
81 msg: format!("{}", error),
82 help: None,
83 }
84
85 @backtraced
86 failed_to_open_file {
87 args: (error: impl Display),
88 msg: format!("Failed to open file {error}"),
89 help: None,
90 }
91
92 @backtraced
93 failed_to_read_file {
94 args: (error: impl Display),
95 msg: format!("Failed to read file {error}"),
96 help: None,
97 }
98
99 @backtraced
100 failed_to_deserialize_file {
101 args: (error: impl Display),
102 msg: format!("Failed to deserialize file {error}"),
103 help: None,
104 }
105
106 @formatted
107 failed_to_retrieve_dependencies {
108 args: (error: impl Display),
109 msg: format!("Failed to retrieve dependencies. {error}"),
110 help: None,
111 }
112
113 @formatted
114 missing_network_error {
115 args: (dependency: impl Display),
116 msg: format!("Dependency {dependency} is missing a network specification"),
117 help: Some("Add a network specification to the dependency in the `program.json` file. Example: `network: \"testnet\"`".to_string()),
118 }
119
120 @formatted
121 missing_path_error {
122 args: (dependency: impl Display),
123 msg: format!("Local dependency {dependency} is missing a path specification"),
124 help: Some("Add a path in the `program.json` file to the dependency project root . Example: `path: \"../../board\"`".to_string()),
125 }
126
127 @formatted
128 program_name_mismatch_error {
129 args: (program_json_name: impl Display, dep_name: impl Display, path: impl Display),
130 msg: format!("Name mismatch: Local program at path `{path}` is named `{program_json_name}` in `program.json` but `{dep_name}` in the program that imports it"),
131 help: Some("Change one of the names to match the other".to_string()),
132 }
133
134 @formatted
135 snarkvm_error_building_program_id {
136 args: (),
137 msg: "Snarkvm error building program id".to_string(),
138 help: None,
139 }
140
141 @backtraced
142 failed_to_retrieve_from_endpoint {
143 args: (error: impl ErrorArg),
144 msg: format!("{error}"),
145 help: None,
146 }
147
148 @formatted
149 build_file_does_not_exist {
150 args: (path: impl Display),
151 msg: format!("Compiled file at `{path}` does not exist, cannot compile parent."),
152 help: Some("If you were using the `--non-recursive` flag, remove it and try again.".to_string()),
153 }
154
155 @backtraced
156 invalid_input_id_len {
157 args: (input: impl Display, expected_type: impl Display),
158 msg: format!("Invalid input: {input}."),
159 help: Some(format!("Type `{expected_type}` must contain exactly 61 lowercase characters or numbers.")),
160 }
161
162 @backtraced
163 invalid_input_id {
164 args: (input: impl Display, expected_type: impl Display, expected_preface: impl Display),
165 msg: format!("Invalid input: {input}."),
166 help: Some(format!("Type `{expected_type}` must start with \"{expected_preface}\".")),
167 }
168
169 @backtraced
170 invalid_numerical_input {
171 args: (input: impl Display),
172 msg: format!("Invalid numerical input: {input}."),
173 help: Some("Input must be a valid u32.".to_string()),
174 }
175
176 @backtraced
177 invalid_range {
178 args: (),
179 msg: "The range must be less than or equal to 50 blocks.".to_string(),
180 help: None,
181 }
182
183 @backtraced
184 invalid_height_or_hash {
185 args: (input: impl Display),
186 msg: format!("Invalid input: {input}."),
187 help: Some("Input must be a valid height or hash. Valid hashes are 61 characters long, composed of only numbers and lower case letters, and be prefaced with \"ab1\".".to_string()),
188 }
189
190 @backtraced
191 invalid_field {
192 args: (field: impl Display),
193 msg: format!("Invalid field: {field}."),
194 help: Some("Field element must be numerical string with optional \"field\" suffix.".to_string()),
195 }
196
197 @backtraced
198 invalid_bound {
199 args: (bound: impl Display),
200 msg: format!("Invalid bound: {bound}."),
201 help: Some("Bound must be a valid u32.".to_string()),
202 }
203
204 @backtraced
205 endpoint_moved_error {
206 args: (endpoint: impl Display),
207 msg: format!("The endpoint `{endpoint}` has been permanently moved."),
208 help: Some("Try using `https://api.explorer.provable.com/v1` in your `.env` file or via the `--endpoint` flag.".to_string()),
209 }
210);