leo_errors/errors/flattener/flattener_errors.rs
1// Copyright (C) 2019-2025 Provable Inc.
2// This file is part of the Leo library.
3
4// The Leo library is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// The Leo library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
16
17use crate::create_messages;
18use std::fmt::{Debug, Display};
19
20create_messages!(
21 /// CliError enum that represents all the errors for the `leo-lang` crate.
22 FlattenError,
23 code_mask: 3000i32,
24 code_prefix: "FLA",
25
26 // TODO: This error is unused.
27 @formatted
28 binary_overflow {
29 args: (left: impl Display, op: impl Display, right: impl Display, right_type: impl Display),
30 msg: format!("The const operation `{left}{} {op} {right}{right_type}` causes an overflow.", 0u32),
31 help: None,
32 }
33
34 // TODO: This error is unused.
35 @formatted
36 unary_overflow {
37 args: (left: impl Display, op: impl Display),
38 msg: format!("The const operation `{left}{} {op}` causes an overflow.", 0u32),
39 help: None,
40 }
41
42 /// For when a loop uses a negative value.
43 @formatted
44 loop_has_neg_value {
45 args: (value: impl Display),
46 msg: format!(
47 "The loop has a negative loop bound `{value}`.",
48 ),
49 help: None,
50 }
51
52 /// For when a u128 value cannot be converted into an i128.
53 @formatted
54 u128_to_i128 {
55 args: (value: impl Display),
56 msg: format!(
57 "The value `{value}` cannot be converted into an i128.",
58 ),
59 help: None,
60 }
61);