1use nv_redfish_core::Bmc;
17use serde_json::Error as JsonError;
18use std::error::Error as StdError;
19use std::fmt::Debug;
20use std::fmt::Display;
21use std::fmt::Formatter;
22use std::fmt::Result as FmtResult;
23
24pub enum Error<B: Bmc> {
26 Bmc(B::Error),
28 #[cfg(feature = "accounts")]
30 AccountServiceNotSupported,
31 #[cfg(feature = "accounts")]
34 AccountSlotNotAvailable,
35 #[cfg(feature = "assembly")]
37 AssemblyNotAvailable,
38 #[cfg(feature = "chassis")]
40 ChassisNotSupported,
41 #[cfg(feature = "computer-systems")]
43 SystemNotSupported,
44 #[cfg(feature = "computer-systems")]
46 ProcessorsNotAvailable,
47 #[cfg(feature = "computer-systems")]
49 StorageNotAvailable,
50 #[cfg(feature = "computer-systems")]
52 MemoryNotAvailable,
53 MetricsNotAvailable,
55 #[cfg(feature = "update-service")]
57 UpdateServiceNotSupported,
58 #[cfg(feature = "update-service")]
60 FirmwareInventoryNotAvailable,
61 #[cfg(feature = "update-service")]
63 SoftwareInventoryNotAvailable,
64 ActionNotAvailable,
66 SensorsNotAvailable,
68 #[cfg(feature = "log-services")]
70 LogServiceNotAvailable,
71 #[cfg(feature = "log-services")]
73 LogEntriesNotAvailable,
74 #[cfg(feature = "managers")]
76 ManagerNotSupported,
77 #[cfg(feature = "ethernet-interfaces")]
79 EthernetInterfacesNotAvailable,
80 #[cfg(feature = "network-adapters")]
82 NetworkAdaptersNotAvailable,
83 #[cfg(feature = "boot-options")]
85 BootOptionsNotAvailable,
86 #[cfg(feature = "pcie-devices")]
88 PcieDevicesNotAvailable,
89 #[cfg(feature = "bios")]
91 BiosNotAvailable,
92 #[cfg(feature = "oem-nvidia-bluefield")]
94 NvidiaComputerSystemNotAvailable,
95 #[cfg(feature = "oem-nvidia-baseboard")]
97 NvidiaCbcChassisNotAvailable,
98 #[cfg(feature = "secure-boot")]
100 SecureBootNotAvailable,
101 Json(JsonError),
103}
104
105impl<B: Bmc> Display for Error<B> {
106 #[allow(clippy::too_many_lines)]
107 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
108 match self {
109 Self::Bmc(err) => write!(f, "BMC error: {err}"),
110 Self::Json(err) => write!(f, "JSON error: {err}"),
111 #[cfg(feature = "accounts")]
112 Self::AccountServiceNotSupported => {
113 write!(f, "Account service is not supported by system")
114 }
115 #[cfg(feature = "accounts")]
116 Self::AccountSlotNotAvailable => {
117 write!(f, "Free account slot is not found")
118 }
119 #[cfg(feature = "assembly")]
120 Self::AssemblyNotAvailable => {
121 write!(f, "Assembly is not available")
122 }
123 #[cfg(feature = "chassis")]
124 Self::ChassisNotSupported => {
125 write!(f, "Chassis is not supported by system")
126 }
127 #[cfg(feature = "computer-systems")]
128 Self::SystemNotSupported => {
129 write!(f, "Computer system is not supported by system")
130 }
131 #[cfg(feature = "computer-systems")]
132 Self::ProcessorsNotAvailable => {
133 write!(f, "Processors are not available for this system")
134 }
135 #[cfg(feature = "computer-systems")]
136 Self::StorageNotAvailable => {
137 write!(f, "Storage is not available for this system")
138 }
139 #[cfg(feature = "computer-systems")]
140 Self::MemoryNotAvailable => {
141 write!(f, "Memory is not available for this system")
142 }
143 Self::MetricsNotAvailable => {
144 write!(f, "Metrics are not available for this entity")
145 }
146 #[cfg(feature = "update-service")]
147 Self::UpdateServiceNotSupported => {
148 write!(f, "Update service is not supported by system")
149 }
150 #[cfg(feature = "update-service")]
151 Self::FirmwareInventoryNotAvailable => {
152 write!(f, "Firmware inventory is not available")
153 }
154 #[cfg(feature = "update-service")]
155 Self::SoftwareInventoryNotAvailable => {
156 write!(f, "Software inventory is not available")
157 }
158 Self::ActionNotAvailable => {
159 write!(f, "Action is not available for this resource")
160 }
161 Self::SensorsNotAvailable => {
162 write!(f, "Sensors is not available for this resource")
163 }
164 #[cfg(feature = "log-services")]
165 Self::LogServiceNotAvailable => {
166 write!(f, "Log service is not available for this resource")
167 }
168 #[cfg(feature = "log-services")]
169 Self::LogEntriesNotAvailable => {
170 write!(f, "Log entries are not available")
171 }
172 #[cfg(feature = "ethernet-interfaces")]
173 Self::EthernetInterfacesNotAvailable => {
174 write!(f, "Ethernet interfaces are not available")
175 }
176 #[cfg(feature = "managers")]
177 Self::ManagerNotSupported => {
178 write!(f, "Manager is not supported by system")
179 }
180 #[cfg(feature = "network-adapters")]
181 Self::NetworkAdaptersNotAvailable => {
182 write!(f, "Network adpaters are not available")
183 }
184 #[cfg(feature = "boot-options")]
185 Self::BootOptionsNotAvailable => {
186 write!(f, "Boot options are not available")
187 }
188 #[cfg(feature = "pcie-devices")]
189 Self::PcieDevicesNotAvailable => {
190 write!(f, "PCIe devices are not available")
191 }
192 #[cfg(feature = "bios")]
193 Self::BiosNotAvailable => {
194 write!(f, "Bios settings are not available")
195 }
196 #[cfg(feature = "oem-nvidia-bluefield")]
197 Self::NvidiaComputerSystemNotAvailable => {
198 write!(
199 f,
200 "NVIDIA OEM extension for computer system is not available"
201 )
202 }
203 #[cfg(feature = "oem-nvidia-baseboard")]
204 Self::NvidiaCbcChassisNotAvailable => {
205 write!(f, "NVIDIA OEM extension for CBC chassis is not available")
206 }
207 #[cfg(feature = "secure-boot")]
208 Self::SecureBootNotAvailable => {
209 write!(f, "Secure boot is not available")
210 }
211 }
212 }
213}
214
215impl<B: Bmc> Debug for Error<B> {
216 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
217 Display::fmt(self, f)
218 }
219}
220
221impl<B: Bmc> StdError for Error<B> {}