1use crate::create_messages;
18use std::{
19 error::Error as ErrorArg,
20 fmt::{Debug, Display},
21};
22
23create_messages!(
24 CliError,
26 code_mask: 7000i32,
27 code_prefix: "CLI",
28
29 @backtraced
31 cli_io_error {
32 args: (error: impl ErrorArg),
33 msg: format!("cli io error {error}"),
34 help: None,
35 }
36
37 @backtraced
39 cli_invalid_input {
40 args: (error: impl Display),
41 msg: format!("cli input error: {error}"),
42 help: None,
43 }
44
45 @backtraced
47 cli_runtime_error {
48 args: (error: impl Display),
49 msg: format!("cli error: {error}"),
50 help: None,
51 }
52
53 @backtraced
55 could_not_fetch_versions {
56 args: (error: impl ErrorArg),
57 msg: format!("Could not fetch versions: {error}"),
58 help: None,
59 }
60
61 @backtraced
63 failed_to_enable_ansi_support {
64 args: (),
65 msg: "failed to enable ansi_support",
66 help: None,
67 }
68
69 @backtraced
71 self_update_error {
72 args: (error: impl ErrorArg),
73 msg: format!("self update crate Error: {error}"),
74 help: None,
75 }
76
77 @backtraced
79 self_update_build_error {
80 args: (error: impl ErrorArg),
81 msg: format!("self update crate failed to build Error: {error}"),
82 help: None,
83 }
84
85 @backtraced
87 old_release_version {
88 args: (current: impl Display, latest: impl Display),
89 msg: format!("Old release version {current} {latest}"),
90 help: None,
91 }
92
93 @backtraced
94 failed_to_load_instructions {
95 args: (error: impl Display),
96 msg: format!("Failed to load compiled Aleo instructions into an Aleo file.\nError: {error}"),
97 help: Some("Generated Aleo instructions have been left in `main.aleo`".to_string()),
98 }
99
100 @backtraced
101 needs_leo_build {
102 args: (),
103 msg: "You must run leo build before deploying a program.".to_string(),
104 help: None,
105 }
106
107 @backtraced
108 failed_to_execute_build {
109 args: (error: impl Display),
110 msg: format!("Failed to execute the `build` command.\nError: {error}"),
111 help: None,
112 }
113
114 @backtraced
115 failed_to_execute_new {
116 args: (error: impl Display),
117 msg: format!("Failed to execute the `new` command.\nError: {error}"),
118 help: None,
119 }
120
121 @backtraced
122 failed_to_execute_run {
123 args: (error: impl Display),
124 msg: format!("Failed to execute the `run` command.\nError: {error}"),
125 help: None,
126 }
127
128 @backtraced
129 failed_to_execute_node {
130 args: (error: impl Display),
131 msg: format!("Failed to execute the `node` command.\nError: {error}"),
132 help: None,
133 }
134
135 @backtraced
136 failed_to_execute_deploy {
137 args: (error: impl Display),
138 msg: format!("Failed to execute the `deploy` command.\nError: {error}"),
139 help: None,
140 }
141
142 @backtraced
143 failed_to_parse_new {
144 args: (error: impl Display),
145 msg: format!("Failed to parse the `new` command.\nError: {error}"),
146 help: None,
147 }
148
149 @backtraced
150 failed_to_parse_run {
151 args: (error: impl Display),
152 msg: format!("Failed to parse the `run` command.\nError: {error}"),
153 help: None,
154 }
155
156 @backtraced
157 failed_to_parse_node {
158 args: (error: impl Display),
159 msg: format!("Failed to parse the `node` command.\nError: {error}"),
160 help: None,
161 }
162
163 @backtraced
164 failed_to_parse_deploy {
165 args: (error: impl Display),
166 msg: format!("Failed to parse the `deploy` command.\nError: {error}"),
167 help: None,
168 }
169
170 @backtraced
171 failed_to_parse_execute {
172 args: (error: impl Display),
173 msg: format!("Failed to parse the `execute` command.\nError: {error}"),
174 help: None,
175 }
176
177 @backtraced
178 failed_to_execute_execute {
179 args: (error: impl Display),
180 msg: format!("Failed to execute the `execute` command.\nError: {error}"),
181 help: None,
182 }
183
184 @backtraced
185 failed_to_parse_seed {
186 args: (error: impl Display),
187 msg: format!("Failed to parse the seed string for account.\nError: {error}"),
188 help: None,
189 }
190
191 @backtraced
192 failed_to_write_file {
193 args: (error: impl Display),
194 msg: format!("Failed to write file.\nIO Error: {error}"),
195 help: None,
196 }
197
198 @backtraced
199 failed_to_parse_private_key {
200 args: (error: impl Display),
201 msg: format!("Failed to parse private key.\nError: {error}"),
202 help: None,
203 }
204
205 @backtraced
206 failed_to_execute_account {
207 args: (error: impl Display),
208 msg: format!("Failed to execute the `account` command.\nError: {error}"),
209 help: None,
210 }
211
212 @backtraced
213 failed_to_read_environment_private_key {
214 args: (error: impl Display),
215 msg: format!("Failed to read private key from environment.\nIO Error: {error}"),
216 help: Some("Pass in private key using `--private-key <PRIVATE-KEY>` or create a .env file with your private key information. See examples for formatting information.".to_string()),
217 }
218
219 @backtraced
220 recursive_deploy_with_record {
221 args: (),
222 msg: "Cannot combine recursive deploy with private fee.".to_string(),
223 help: None,
224 }
225
226 @backtraced
227 invalid_network_name {
228 args: (network: impl Display),
229 msg: format!("Invalid network name: {network}"),
230 help: Some("Valid network names are `testnet`, `mainnet`, and `canary`.".to_string()),
231 }
232
233 @backtraced
234 invalid_example {
235 args: (example: impl Display),
236 msg: format!("Invalid Leo example: {example}"),
237 help: Some("Valid Leo examples are `lottery`, `tictactoe`, and `token`.".to_string()),
238 }
239
240 @backtraced
241 build_error {
242 args: (error: impl Display),
243 msg: format!("Failed to build program: {error}"),
244 help: None,
245 }
246
247 @backtraced
248 failed_to_parse_record {
249 args: (error: impl Display),
250 msg: format!("Failed to parse the record string.\nSnarkVM Error: {error}"),
251 help: None,
252 }
253
254 @backtraced
255 string_parse_error {
256 args: (error: impl Display),
257 msg: format!("{error}"),
258 help: None,
259 }
260
261 @backtraced
262 broadcast_error {
263 args: (error: impl Display),
264 msg: format!("{error}"),
265 help: None,
266 }
267
268 @backtraced
269 failed_to_get_endpoint_from_env {
270 args: (),
271 msg: "Failed to get an endpoint.".to_string(),
272 help: Some("Either make sure you have a `.env` file in current project directory with an `ENDPOINT` variable set, or set the `--endpoint` flag when invoking the CLI command.\n Example: `ENDPOINT=https://api.explorer.provable.com/v1` or `leo build --endpoint \"https://api.explorer.provable.com/v1\"`.".to_string()),
273 }
274
275 @backtraced
276 failed_to_get_private_key_from_env {
277 args: (),
278 msg: "Failed to get a private key.".to_string(),
279 help: Some("Either make sure you have a `.env` file in current project directory with a `PRIVATE_KEY` variable set, or set the `--private-key` flag when invoking the CLI command.\n Example: `PRIVATE_KEY=0x1234...` or `leo deploy --private-key \"APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH\"`.".to_string()),
280 }
281
282 @backtraced
283 failed_to_get_network_from_env {
284 args: (),
285 msg: "Failed to get a network.".to_string(),
286 help: Some("Either make sure you have a `.env` file in current project directory with a `NETWORK` variable set, or set the `--network` flag when invoking the CLI command.\n Example: `NETWORK=testnet` or `leo build --network testnet`.".to_string()),
287 }
288
289 @backtraced
290 constraint_limit_exceeded {
291 args: (program: impl Display, actual: u64, limit: u64, network: impl Display),
292 msg: format!("Program `{program}` has {actual} constraints, which exceeds the limit of {limit} for deployment on network {network}."),
293 help: Some("Reduce the number of constraints in the program by reducing the number of instructions in transition functions.".to_string()),
294 }
295
296 @backtraced
297 variable_limit_exceeded {
298 args: (program: impl Display, actual: u64, limit: u64, network: impl Display),
299 msg: format!("Program `{program}` has {actual} variables, which exceeds the limit of {limit} for deployment on network {network}."),
300 help: Some("Reduce the number of variables in the program by reducing the number of instructions in transition functions.".to_string()),
301 }
302
303 @backtraced
304 confirmation_failed {
305 args: (),
306 msg: "Failed to confirm transaction".to_string(),
307 help: None,
308 }
309
310 @backtraced
311 invalid_balance {
312 args: (account: impl Display),
313 msg: format!("Invalid public balance for account: {account}"),
314 help: Some("Make sure the account has enough balance to pay for the deployment.".to_string()),
315 }
316
317 @backtraced
318 table_render_failed {
319 args: (error: impl Display),
320 msg: format!("Failed to render table.\nError: {error}"),
321 help: None,
322 }
323
324 @backtraced
325 invalid_program_name {
326 args: (name: impl Display),
327 msg: format!("Invalid program name `{name}`"),
328 help: None,
329 }
330
331 @backtraced
332 custom {
333 args: (msg: impl Display),
334 msg: format!("{msg}"),
335 help: None,
336 }
337);