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
80 reqwest_error {
81 args: (error: impl Display),
82 msg: format!("{}", error),
83 help: None,
84 }
85
86 @backtraced
87 failed_to_open_file {
88 args: (error: impl Display),
89 msg: format!("Failed to open file {error}"),
90 help: None,
91 }
92
93 @backtraced
94 failed_to_read_file {
95 args: (error: impl Display),
96 msg: format!("Failed to read file {error}"),
97 help: None,
98 }
99
100 @backtraced
101 failed_to_deserialize_file {
102 args: (error: impl Display),
103 msg: format!("Failed to deserialize file {error}"),
104 help: None,
105 }
106
107 @formatted
108 failed_to_retrieve_dependencies {
109 args: (error: impl Display),
110 msg: format!("Failed to retrieve dependencies. {error}"),
111 help: None,
112 }
113
114 @formatted
115 missing_network_error {
116 args: (dependency: impl Display),
117 msg: format!("Dependency {dependency} is missing a network specification"),
118 help: Some("Add a network specification to the dependency in the `program.json` file. Example: `network: \"testnet\"`".to_string()),
119 }
120
121 @formatted
122 missing_path_error {
123 args: (dependency: impl Display),
124 msg: format!("Local dependency {dependency} is missing a path specification"),
125 help: Some("Add a path in the `program.json` file to the dependency project root . Example: `path: \"../../board\"`".to_string()),
126 }
127
128 @formatted
129 program_name_mismatch_error {
130 args: (program_json_name: impl Display, dep_name: impl Display, path: impl Display),
131 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"),
132 help: Some("Change one of the names to match the other".to_string()),
133 }
134
135 @formatted
136 snarkvm_error_building_program_id {
137 args: (),
138 msg: "Snarkvm error building program id".to_string(),
139 help: None,
140 }
141
142 @backtraced
143 failed_to_retrieve_from_endpoint {
144 args: (url: impl Display, error: impl Display),
145 msg: format!("Failed to retrieve from endpoint `{url}`: {error}"),
146 help: None,
147 }
148
149 @formatted
150 build_file_does_not_exist {
151 args: (path: impl Display),
152 msg: format!("Compiled file at `{path}` does not exist, cannot compile parent."),
153 help: Some("If you were using the `--non-recursive` flag, remove it and try again.".to_string()),
154 }
155
156 @backtraced
157 invalid_input_id_len {
158 args: (input: impl Display, expected_type: impl Display),
159 msg: format!("Invalid input: {input}."),
160 help: Some(format!("Type `{expected_type}` must contain exactly 61 lowercase characters or numbers.")),
161 }
162
163 @backtraced
164 invalid_input_id {
165 args: (input: impl Display, expected_type: impl Display, expected_preface: impl Display),
166 msg: format!("Invalid input: {input}."),
167 help: Some(format!("Type `{expected_type}` must start with \"{expected_preface}\".")),
168 }
169
170 @backtraced
171 invalid_numerical_input {
172 args: (input: impl Display),
173 msg: format!("Invalid numerical input: {input}."),
174 help: Some("Input must be a valid u32.".to_string()),
175 }
176
177 @backtraced
178 invalid_range {
179 args: (),
180 msg: "The range must be less than or equal to 50 blocks.".to_string(),
181 help: None,
182 }
183
184 @backtraced
185 invalid_height_or_hash {
186 args: (input: impl Display),
187 msg: format!("Invalid input: {input}."),
188 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()),
189 }
190
191 @backtraced
192 invalid_field {
193 args: (field: impl Display),
194 msg: format!("Invalid field: {field}."),
195 help: Some("Field element must be numerical string with optional \"field\" suffix.".to_string()),
196 }
197
198 @backtraced
199 invalid_bound {
200 args: (bound: impl Display),
201 msg: format!("Invalid bound: {bound}."),
202 help: Some("Bound must be a valid u32.".to_string()),
203 }
204
205 @backtraced
206 endpoint_moved_error {
207 args: (endpoint: impl Display),
208 msg: format!("The endpoint `{endpoint}` has been permanently moved."),
209 help: Some("Try using `https://api.explorer.provable.com/v1` in your `.env` file or via the `--endpoint` flag.".to_string()),
210 }
211);