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