1use std::fmt::{Debug};
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum Error {
6 #[error("")]
7 CannotDeserializeDataPoint,
8 #[error("")]
9 InvalidData,
10 #[error("Data length not correct")]
11 InvalidDataLength,
12 #[error("Invalid data type")]
13 InvalidDataType,
14 #[error("Beacon data not found")]
15 BeaconDataNotFound,
16 #[error("Fulfillment older than Beacon")]
17 FulfillmentOlderThanBeacon,
18 #[error("Invalid name: {0}")]
19 InvalidName(String),
20 #[error("Parameter length mismatch")]
21 ParameterLengthMismatch,
22 #[error("Specified less than two Beacons")]
23 LessThanTwoBeacons,
24 #[error("Timestamp not valid")]
25 InvalidTimestamp,
26 #[error("Signature mismatch")]
27 InvalidSignature,
28 #[error("Updated value outdated")]
29 UpdatedValueOutdated,
30 #[error("Does not extend expiration")]
31 DoesNotExtendExpiration,
32 #[error("Access Denied")]
33 AccessDenied,
34 #[error("NameHash Not Found")]
35 NameHashNotFound,
36 #[error("Role description Empty")]
37 RoleDescriptionEmpty,
38 #[error("Service ID zero")]
39 ServiceIdZero,
40 #[error("User address zero")]
41 UserAddressZero,
42 #[error("Invalid Address")]
43 InvalidAddress,
44 #[error("Only Renounce roles for self")]
45 OnlyRenounceRolesForSelf,
46 #[error("Not authorized to perform this action")]
47 NotAuthorized,
48 #[error("Role admin not found")]
49 RoleAdminNotFound,
50 #[error("Contract already initialized")]
51 AlreadyInitialized,
52 #[error("Cannot set indefinite status")]
53 CannotSetIndefiniteStatus,
54 #[error("Template id cannot be zero")]
55 TemplateIdZero,
56 #[error("Airnode id cannot be zero")]
57 AirnodeIdZero,
58 #[error("Setter can set indefinite status")]
59 SetterCanSetIndefiniteStatus
60}
61
62impl From<Error> for u32 {
63 fn from(e: Error) -> Self {
64 match e {
65 Error::CannotDeserializeDataPoint => 0,
66 Error::InvalidData => 1,
67 Error::InvalidDataLength => 2,
68 Error::InvalidDataType => 3,
69 Error::BeaconDataNotFound => 4,
70 Error::FulfillmentOlderThanBeacon => 5,
71 Error::InvalidName(_) => 6,
72 Error::ParameterLengthMismatch => 9,
73 Error::LessThanTwoBeacons => 10,
74 Error::InvalidTimestamp => 11,
75 Error::InvalidSignature => 12,
76 Error::UpdatedValueOutdated => 13,
77 Error::AccessDenied => 14,
78 Error::NameHashNotFound => 15,
79 Error::RoleDescriptionEmpty => 16,
80 Error::DoesNotExtendExpiration => 17,
81 Error::ServiceIdZero => 18,
82 Error::UserAddressZero => 19,
83 Error::InvalidAddress => 20,
84 Error::OnlyRenounceRolesForSelf => 21,
85 Error::NotAuthorized => 22,
86 Error::RoleAdminNotFound => 23,
87 Error::AlreadyInitialized => 24,
88 Error::CannotSetIndefiniteStatus => 25,
89 Error::TemplateIdZero => 26,
90 Error::AirnodeIdZero => 27,
91 Error::SetterCanSetIndefiniteStatus => 28,
92 }
93 }
94}