Rekha Aparna | 5e3ff85 | 2025-08-12 10:51:23 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Rekha Aparna | 9443af2 | 2025-08-28 02:40:08 -0500 | [diff] [blame] | 3 | #include <string> |
| 4 | #include <unordered_map> |
| 5 | |
Rekha Aparna | 5e3ff85 | 2025-08-12 10:51:23 -0500 | [diff] [blame] | 6 | namespace vpd |
| 7 | { |
| 8 | namespace error_code |
| 9 | { |
| 10 | // File exceptions |
| 11 | static constexpr auto FILE_NOT_FOUND = 1001; |
| 12 | static constexpr auto FILE_ACCESS_ERROR = 1002; |
| 13 | static constexpr auto EMPTY_FILE = 1003; |
| 14 | |
| 15 | // JSON exceptions |
| 16 | static constexpr auto INVALID_JSON = 2001; |
| 17 | static constexpr auto MISSING_FLAG = 2002; |
| 18 | static constexpr auto MISSING_ACTION_TAG = 2003; |
| 19 | static constexpr auto FRU_PATH_NOT_FOUND = 2004; |
Rekha Aparna | ca9a086 | 2025-08-29 04:08:33 -0500 | [diff] [blame] | 20 | static constexpr auto JSON_PARSE_ERROR = 2005; |
Sunny Srivastava | 84c3d23 | 2025-09-03 00:47:10 -0500 | [diff] [blame] | 21 | static constexpr auto JSON_MISSING_GPIO_INFO = 2006; |
Rekha Aparna | 5e3ff85 | 2025-08-12 10:51:23 -0500 | [diff] [blame] | 22 | |
| 23 | // Generic errors. |
Rekha Aparna | 017567a | 2025-08-13 02:07:06 -0500 | [diff] [blame] | 24 | static constexpr auto INVALID_INPUT_PARAMETER = 3001; |
Sunny Srivastava | 84c3d23 | 2025-09-03 00:47:10 -0500 | [diff] [blame] | 25 | static constexpr auto DEVICE_NOT_PRESENT = 2006; |
| 26 | static constexpr auto DEVICE_PRESENCE_UNKNOWN = 2007; |
| 27 | static constexpr auto GPIO_LINE_EXCEPTION = 2008; |
Rekha Aparna | 9443af2 | 2025-08-28 02:40:08 -0500 | [diff] [blame] | 28 | |
| 29 | const std::unordered_map<int, std::string> errorCodeMap = { |
| 30 | {FILE_NOT_FOUND, "File does not exist."}, |
| 31 | {FILE_ACCESS_ERROR, "Failed to access the file."}, |
| 32 | {EMPTY_FILE, "Empty file."}, |
| 33 | {INVALID_JSON, "Either JSON is missing FRU tag or invalid JSON object."}, |
| 34 | {MISSING_FLAG, "JSON is missing the flag to procees for the FRU."}, |
| 35 | {MISSING_ACTION_TAG, |
| 36 | "JSON is missing the action tag to be performed for the FRU."}, |
| 37 | {FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."}, |
Rekha Aparna | ca9a086 | 2025-08-29 04:08:33 -0500 | [diff] [blame] | 38 | {JSON_PARSE_ERROR, "Error while parsing JSON file."}, |
Rekha Aparna | 017567a | 2025-08-13 02:07:06 -0500 | [diff] [blame] | 39 | {INVALID_INPUT_PARAMETER, |
Sunny Srivastava | 84c3d23 | 2025-09-03 00:47:10 -0500 | [diff] [blame] | 40 | "Either one of the input parameter is invalid or empty."}, |
| 41 | {JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."}, |
| 42 | {DEVICE_NOT_PRESENT, |
| 43 | "Presence pin read successfully but device was absent."}, |
| 44 | {DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."}, |
| 45 | {GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."}}; |
Rekha Aparna | 5e3ff85 | 2025-08-12 10:51:23 -0500 | [diff] [blame] | 46 | } // namespace error_code |
| 47 | } // namespace vpd |