blob: 1dd6029fe34c2db60b783b253325bf5684d19185 [file] [log] [blame]
Alexander Hansenc0f7a8b2024-08-23 19:44:22 +02001#pragma once
2
Alexander Hansen638d1482024-08-21 17:39:57 +02003#include "grouplayout.hpp"
4#include "ledlayout.hpp"
5
6#include <phosphor-logging/lg2.hpp>
7#include <sdbusplus/bus.hpp>
8
9namespace phosphor
10{
11namespace led
12{
13namespace error
14{
15enum ConfigValidationError
16{
17 // An LED has different priorities assigned to it in different groups
18 LedPriorityMismatch,
19
20 // LED priority was needed but not assigned
21 MissingLedPriority,
22
23 // Mixup of the 2 configuration options
24 MixedLedAndGroupPriority,
25
26 // An invalid group priority was assigned
27 InvalidGroupPriority,
28
29 // Group priorities were not unique
30 DuplicateGroupPriority,
31};
32}
33
34class ConfigValidationException : std::runtime_error
35{
36 public:
37 error::ConfigValidationError reason;
38
39 ConfigValidationException(const error::ConfigValidationError& err,
40 const std::string& msg) :
41 std::runtime_error(msg), reason(err)
42 {
43 lg2::error(msg.c_str());
44 }
45
46 ConfigValidationException(const error::ConfigValidationError& err,
47 const std::string& groupName,
48 const std::string& msg) :
49 std::runtime_error(msg), reason(err)
50 {
51 lg2::error("Configuration Validation Error in Group {GROUP}: {MSG}",
52 "GROUP", groupName, "MSG", msg.c_str());
53 }
54
55 ConfigValidationException(const error::ConfigValidationError& err,
56 const std::string& groupName,
57 const std::string& ledName,
58 const std::string& msg) :
59 std::runtime_error(msg), reason(err)
60 {
61 lg2::error(
62 "Configuration Validation Error in Group {GROUP}, Led {LED}: {MSG}",
63 "GROUP", groupName, "LED", ledName, "MSG", msg.c_str());
64 }
65};
66
67void validateConfigV1(const phosphor::led::GroupMap& ledMap);
68
69} // namespace led
70} // namespace phosphor