Skip to content

Commit ebcc194

Browse files
committed
Add new error types
Add ImageFailure and BusyFailure for error reporting. Rerun elog-errors script to generate error data. Change-Id: I1f9ec4766d510abe612db2453dcf36325c7dd2f4 Signed-off-by: James Feist <[email protected]>
1 parent f7a69e1 commit ebcc194

File tree

3 files changed

+200
-69
lines changed

3 files changed

+200
-69
lines changed

elog-errors.hpp

Lines changed: 182 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Image
2222
{
2323
namespace Error
2424
{
25-
struct UnTarFailure;
25+
struct ManifestFileFailure;
2626
} // namespace Error
2727
} // namespace Image
2828
} // namespace Software
@@ -42,7 +42,7 @@ namespace Image
4242
{
4343
namespace Error
4444
{
45-
struct InternalFailure;
45+
struct ImageFailure;
4646
} // namespace Error
4747
} // namespace Image
4848
} // namespace Software
@@ -62,7 +62,47 @@ namespace Image
6262
{
6363
namespace Error
6464
{
65-
struct ManifestFileFailure;
65+
struct BusyFailure;
66+
} // namespace Error
67+
} // namespace Image
68+
} // namespace Software
69+
} // namespace openbmc_project
70+
} // namespace xyz
71+
} // namespace sdbusplus
72+
73+
namespace sdbusplus
74+
{
75+
namespace xyz
76+
{
77+
namespace openbmc_project
78+
{
79+
namespace Software
80+
{
81+
namespace Image
82+
{
83+
namespace Error
84+
{
85+
struct UnTarFailure;
86+
} // namespace Error
87+
} // namespace Image
88+
} // namespace Software
89+
} // namespace openbmc_project
90+
} // namespace xyz
91+
} // namespace sdbusplus
92+
93+
namespace sdbusplus
94+
{
95+
namespace xyz
96+
{
97+
namespace openbmc_project
98+
{
99+
namespace Software
100+
{
101+
namespace Image
102+
{
103+
namespace Error
104+
{
105+
struct InternalFailure;
66106
} // namespace Error
67107
} // namespace Image
68108
} // namespace Software
@@ -89,38 +129,24 @@ namespace _UnTarFailure
89129

90130
struct PATH
91131
{
92-
static constexpr auto str = "PATH=%s";
132+
/*
133+
* We can't use -fsanitize=undefined if we declare a
134+
* 'static constexpr auto str' member, so don't. Instead, open-code the
135+
* mako template lookups.
136+
*/
93137
static constexpr auto str_short = "PATH";
94-
using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
95-
explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
138+
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
139+
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
96140
type _entry;
97141
};
98142

99143
} // namespace _UnTarFailure
100144

101-
struct UnTarFailure : public sdbusplus::exception_t
145+
struct UnTarFailure
102146
{
103-
static constexpr auto errName =
104-
"xyz.openbmc_project.Software.Image.UnTarFailure";
105-
static constexpr auto errDesc = "An error occurred during untar.";
106147
static constexpr auto L = level::ERR;
107148
using PATH = _UnTarFailure::PATH;
108149
using metadata_types = std::tuple<PATH>;
109-
110-
const char* name() const noexcept
111-
{
112-
return errName;
113-
}
114-
115-
const char* description() const noexcept
116-
{
117-
return errDesc;
118-
}
119-
120-
const char* what() const noexcept
121-
{
122-
return errName;
123-
}
124150
};
125151

126152
} // namespace Image
@@ -137,6 +163,7 @@ struct map_exception_type<
137163
{
138164
using type = xyz::openbmc_project::Software::Image::UnTarFailure;
139165
};
166+
140167
} // namespace details
141168

142169
namespace xyz
@@ -152,38 +179,24 @@ namespace _ManifestFileFailure
152179

153180
struct PATH
154181
{
155-
static constexpr auto str = "PATH=%s";
182+
/*
183+
* We can't use -fsanitize=undefined if we declare a
184+
* 'static constexpr auto str' member, so don't. Instead, open-code the
185+
* mako template lookups.
186+
*/
156187
static constexpr auto str_short = "PATH";
157-
using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
158-
explicit constexpr PATH(const char* a) : _entry(entry(str, a)){};
188+
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
189+
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
159190
type _entry;
160191
};
161192

162193
} // namespace _ManifestFileFailure
163194

164-
struct ManifestFileFailure : public sdbusplus::exception_t
195+
struct ManifestFileFailure
165196
{
166-
static constexpr auto errName =
167-
"xyz.openbmc_project.Software.Image.ManifestFileFailure";
168-
static constexpr auto errDesc = "An error when reading the Manifest file.";
169197
static constexpr auto L = level::ERR;
170198
using PATH = _ManifestFileFailure::PATH;
171199
using metadata_types = std::tuple<PATH>;
172-
173-
const char* name() const noexcept
174-
{
175-
return errName;
176-
}
177-
178-
const char* description() const noexcept
179-
{
180-
return errDesc;
181-
}
182-
183-
const char* what() const noexcept
184-
{
185-
return errName;
186-
}
187200
};
188201

189202
} // namespace Image
@@ -200,6 +213,7 @@ struct map_exception_type<sdbusplus::xyz::openbmc_project::Software::Image::
200213
{
201214
using type = xyz::openbmc_project::Software::Image::ManifestFileFailure;
202215
};
216+
203217
} // namespace details
204218

205219
namespace xyz
@@ -215,39 +229,87 @@ namespace _InternalFailure
215229

216230
struct FAIL
217231
{
218-
static constexpr auto str = "FAIL=%s";
232+
/*
233+
* We can't use -fsanitize=undefined if we declare a
234+
* 'static constexpr auto str' member, so don't. Instead, open-code the
235+
* mako template lookups.
236+
*/
219237
static constexpr auto str_short = "FAIL";
220-
using type = std::tuple<std::decay_t<decltype(str)>, const char*>;
221-
explicit constexpr FAIL(const char* a) : _entry(entry(str, a)){};
238+
using type = std::tuple<std::decay_t<decltype("FAIL=%s")>, const char*>;
239+
explicit constexpr FAIL(const char* a) : _entry(entry("FAIL=%s", a)){};
222240
type _entry;
223241
};
224242

225243
} // namespace _InternalFailure
226244

227-
struct InternalFailure : public sdbusplus::exception_t
245+
struct InternalFailure
228246
{
229-
static constexpr auto errName =
230-
"xyz.openbmc_project.Software.Image.InternalFailure";
231-
static constexpr auto errDesc =
232-
"The operation failed internally during processing the image.";
233247
static constexpr auto L = level::ERR;
234248
using FAIL = _InternalFailure::FAIL;
235249
using metadata_types = std::tuple<FAIL>;
250+
};
251+
252+
} // namespace Image
253+
} // namespace Software
254+
} // namespace openbmc_project
255+
} // namespace xyz
256+
257+
namespace details
258+
{
259+
260+
template <>
261+
struct map_exception_type<
262+
sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure>
263+
{
264+
using type = xyz::openbmc_project::Software::Image::InternalFailure;
265+
};
236266

237-
const char* name() const noexcept
238-
{
239-
return errName;
240-
}
267+
} // namespace details
241268

242-
const char* description() const noexcept
243-
{
244-
return errDesc;
245-
}
269+
namespace xyz
270+
{
271+
namespace openbmc_project
272+
{
273+
namespace Software
274+
{
275+
namespace Image
276+
{
277+
namespace _ImageFailure
278+
{
246279

247-
const char* what() const noexcept
248-
{
249-
return errName;
250-
}
280+
struct FAIL
281+
{
282+
/*
283+
* We can't use -fsanitize=undefined if we declare a
284+
* 'static constexpr auto str' member, so don't. Instead, open-code the
285+
* mako template lookups.
286+
*/
287+
static constexpr auto str_short = "FAIL";
288+
using type = std::tuple<std::decay_t<decltype("FAIL=%s")>, const char*>;
289+
explicit constexpr FAIL(const char* a) : _entry(entry("FAIL=%s", a)){};
290+
type _entry;
291+
};
292+
struct PATH
293+
{
294+
/*
295+
* We can't use -fsanitize=undefined if we declare a
296+
* 'static constexpr auto str' member, so don't. Instead, open-code the
297+
* mako template lookups.
298+
*/
299+
static constexpr auto str_short = "PATH";
300+
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
301+
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
302+
type _entry;
303+
};
304+
305+
} // namespace _ImageFailure
306+
307+
struct ImageFailure
308+
{
309+
static constexpr auto L = level::ERR;
310+
using FAIL = _ImageFailure::FAIL;
311+
using PATH = _ImageFailure::PATH;
312+
using metadata_types = std::tuple<FAIL, PATH>;
251313
};
252314

253315
} // namespace Image
@@ -260,10 +322,61 @@ namespace details
260322

261323
template <>
262324
struct map_exception_type<
263-
sdbusplus::xyz::openbmc_project::Software::Image::Error::InternalFailure>
325+
sdbusplus::xyz::openbmc_project::Software::Image::Error::ImageFailure>
264326
{
265-
using type = xyz::openbmc_project::Software::Image::InternalFailure;
327+
using type = xyz::openbmc_project::Software::Image::ImageFailure;
328+
};
329+
330+
} // namespace details
331+
332+
namespace xyz
333+
{
334+
namespace openbmc_project
335+
{
336+
namespace Software
337+
{
338+
namespace Image
339+
{
340+
namespace _BusyFailure
341+
{
342+
343+
struct PATH
344+
{
345+
/*
346+
* We can't use -fsanitize=undefined if we declare a
347+
* 'static constexpr auto str' member, so don't. Instead, open-code the
348+
* mako template lookups.
349+
*/
350+
static constexpr auto str_short = "PATH";
351+
using type = std::tuple<std::decay_t<decltype("PATH=%s")>, const char*>;
352+
explicit constexpr PATH(const char* a) : _entry(entry("PATH=%s", a)){};
353+
type _entry;
266354
};
355+
356+
} // namespace _BusyFailure
357+
358+
struct BusyFailure
359+
{
360+
static constexpr auto L = level::ERR;
361+
using PATH = _BusyFailure::PATH;
362+
using metadata_types = std::tuple<PATH>;
363+
};
364+
365+
} // namespace Image
366+
} // namespace Software
367+
} // namespace openbmc_project
368+
} // namespace xyz
369+
370+
namespace details
371+
{
372+
373+
template <>
374+
struct map_exception_type<
375+
sdbusplus::xyz::openbmc_project::Software::Image::Error::BusyFailure>
376+
{
377+
using type = xyz::openbmc_project::Software::Image::BusyFailure;
378+
};
379+
267380
} // namespace details
268381

269382
} // namespace logging

xyz/openbmc_project/Software/Image.errors.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
description: An error when reading the Manifest file.
55
- name: InternalFailure
66
description: The operation failed internally during processing the image.
7+
- name: ImageFailure
8+
description: An error occured processing the image.
9+
- name: BusyFailure
10+
description: The device is busy during the update.
11+

xyz/openbmc_project/Software/Image.metadata.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@
1313
meta:
1414
- str: "FAIL=%s"
1515
type: string
16+
- name: ImageFailure
17+
level: ERR
18+
meta:
19+
- str: "FAIL=%s"
20+
type: string
21+
- str: "PATH=%s"
22+
type: string
23+
- name: BusyFailure
24+
level: ERR
25+
meta:
26+
- str: "PATH=%s"
27+
type: string
28+

0 commit comments

Comments
 (0)