tachyon_math_library/
error.rs1use anchor_lang::error_code;
2
3#[error_code]
4pub enum ErrorCode {
5 #[msg("The program has already been initialized")]
6 ProgramAlreadyInitialized,
7 #[msg("This account has already been initialized")]
8 AccountAlreadyInitialized,
9 #[msg("This function does not take any additional parameters")]
10 FunctionDoesNotTakeAdditionalParams,
11 #[msg("This function requires additional parameters")]
12 FunctionRequiresAdditionalParams,
13 #[msg("The input provided is out of bounds of the available domain")]
14 OutOfDomainBounds,
15 #[msg("The accounts for this function call were not loaded")]
16 MissingDataAccount,
17 #[msg("Not all of the data for this function account has been loaded")]
18 IncompleteDataLoading,
19 #[msg("Data at the requested index has not been populated")]
20 EmptyData,
21 #[msg("Data at the requested index is not a number (infinite)")]
22 NaNData,
23 #[msg("Missing function implementation")]
24 MissingImplementation,
25 #[msg("Invalid index for X value")]
26 InvalidIndex,
27 #[msg("Invalid Y value for X value")]
28 InvalidValue,
29 #[msg("The data at this index has already been loaded")]
30 DataAtIndexAlreadyLoaded,
31}
32
33#[macro_export]
34macro_rules! print_error {
35 ($err:expr) => {{
36 || {
37 let error_code: ErrorCode = $err;
38 msg!("{:?} thrown at {}:{}", error_code, file!(), line!());
39 $err
40 }
41 }};
42}
43
44#[macro_export]
45macro_rules! math_error {
46 () => {{
47 || {
48 let error_code = $crate::error::ErrorCode::MathError;
49 msg!("Error {} thrown at {}:{}", error_code, file!(), line!());
50 error_code
51 }
52 }};
53}