Skip to main content

leo_errors/errors/flattener/
flattener_errors.rs

1// Copyright (C) 2019-2026 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 std::fmt::{Debug, Display};
18
19create_messages!(
20    /// CliError enum that represents all the errors for the `leo-lang` crate.
21    FlattenError,
22    code_mask: 3000i32,
23    code_prefix: "FLA",
24
25    // TODO: This error is unused.
26    @formatted
27    binary_overflow {
28        args: (left: impl Display, op: impl Display, right: impl Display, right_type: impl Display),
29        msg: format!("The const operation `{left}{} {op} {right}{right_type}` causes an overflow.", 0u32),
30        help: None,
31    }
32
33    // TODO: This error is unused.
34    @formatted
35    unary_overflow {
36        args: (left: impl Display, op: impl Display),
37        msg: format!("The const operation `{left}{} {op}` causes an overflow.", 0u32),
38        help: None,
39    }
40
41    /// For when a loop uses a negative value.
42    @formatted
43    loop_has_neg_value {
44        args: (value: impl Display),
45        msg: format!(
46            "The loop has a negative loop bound `{value}`.",
47        ),
48        help: None,
49    }
50
51    /// For when a u128 value cannot be converted into an i128.
52    @formatted
53    u128_to_i128 {
54        args: (value: impl Display),
55        msg: format!(
56            "The value `{value}` cannot be converted into an i128.",
57        ),
58        help: None,
59    }
60);