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