| 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 | 7f6cd4c | 2025-10-06 23:44:04 -0500 | [diff] [blame] | 14 | FILE_SYSTEM_ERROR, |
| Rekha Aparna | 5e3ff85 | 2025-08-12 10:51:23 -0500 | [diff] [blame] | 15 | |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 16 | // JSON exceptions |
| 17 | INVALID_JSON, |
| 18 | MISSING_FLAG, |
| 19 | MISSING_ACTION_TAG, |
| 20 | FRU_PATH_NOT_FOUND, |
| 21 | JSON_PARSE_ERROR, |
| 22 | JSON_MISSING_GPIO_INFO, |
| Rekha Aparna | e0d24c0 | 2025-09-02 00:15:06 -0500 | [diff] [blame] | 23 | JSON_MISSING_SERVICE_NAME, |
| Rekha Aparna | 2d6f071 | 2025-09-02 03:52:57 -0500 | [diff] [blame] | 24 | REDUNDANT_PATH_NOT_FOUND, |
| 25 | ERROR_GETTING_REDUNDANT_PATH, |
| 26 | NO_EEPROM_PATH, |
| Rekha Aparna | 5e3ff85 | 2025-08-12 10:51:23 -0500 | [diff] [blame] | 27 | |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 28 | // Generic errors. |
| 29 | INVALID_INPUT_PARAMETER, |
| 30 | DEVICE_NOT_PRESENT, |
| 31 | DEVICE_PRESENCE_UNKNOWN, |
| Rekha Aparna | 41f47e7 | 2025-09-18 01:44:09 -0500 | [diff] [blame] | 32 | GPIO_LINE_EXCEPTION, |
| Souvik Roy | d7c7cb5 | 2025-07-30 06:31:02 +0000 | [diff] [blame] | 33 | ERROR_PROCESSING_SYSTEM_CMD, |
| 34 | STANDARD_EXCEPTION, |
| Rekha Aparna | 6256db9 | 2025-10-17 09:58:49 -0500 | [diff] [blame] | 35 | DBUS_FAILURE, |
| Souvik Roy | d7c7cb5 | 2025-07-30 06:31:02 +0000 | [diff] [blame] | 36 | |
| 37 | // VPD specific errors |
| Rekha Aparna | 7d9a706 | 2025-10-07 04:14:42 -0500 | [diff] [blame] | 38 | UNSUPPORTED_VPD_TYPE, |
| Rekha Aparna | 17ddfb5 | 2025-10-09 20:45:53 -0500 | [diff] [blame] | 39 | KEYWORD_NOT_FOUND, |
| Rekha Aparna | 6256db9 | 2025-10-17 09:58:49 -0500 | [diff] [blame] | 40 | OUT_OF_BOUND_EXCEPTION, |
| 41 | FAILED_TO_DETECT_LOCATION_CODE_TYPE, |
| 42 | RECEIVED_INVALID_KWD_TYPE_FROM_DBUS |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 43 | }; |
| Rekha Aparna | 9443af2 | 2025-08-28 02:40:08 -0500 | [diff] [blame] | 44 | |
| 45 | const std::unordered_map<int, std::string> errorCodeMap = { |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 46 | {error_code::FILE_NOT_FOUND, "File does not exist."}, |
| 47 | {error_code::FILE_ACCESS_ERROR, "Failed to access the file."}, |
| 48 | {error_code::EMPTY_FILE, "Empty file."}, |
| 49 | {error_code::INVALID_JSON, |
| 50 | "Either JSON is missing FRU tag or invalid JSON object."}, |
| 51 | {error_code::MISSING_FLAG, |
| 52 | "JSON is missing the flag to procees for the FRU."}, |
| 53 | {error_code::MISSING_ACTION_TAG, |
| Rekha Aparna | 9443af2 | 2025-08-28 02:40:08 -0500 | [diff] [blame] | 54 | "JSON is missing the action tag to be performed for the FRU."}, |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 55 | {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."}, |
| 56 | {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."}, |
| 57 | {error_code::INVALID_INPUT_PARAMETER, |
| Sunny Srivastava | 84c3d23 | 2025-09-03 00:47:10 -0500 | [diff] [blame] | 58 | "Either one of the input parameter is invalid or empty."}, |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 59 | {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."}, |
| Rekha Aparna | e0d24c0 | 2025-09-02 00:15:06 -0500 | [diff] [blame] | 60 | {error_code::JSON_MISSING_SERVICE_NAME, |
| 61 | "JSON missing the service name for the FRU"}, |
| Rekha Aparna | 2d6f071 | 2025-09-02 03:52:57 -0500 | [diff] [blame] | 62 | {error_code::REDUNDANT_PATH_NOT_FOUND, "No redundant path for the FRU."}, |
| 63 | {error_code::ERROR_GETTING_REDUNDANT_PATH, |
| 64 | "Error while trying to get redundant path for the FRU"}, |
| 65 | {error_code::NO_EEPROM_PATH, "EEPROM path not found."}, |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 66 | {error_code::DEVICE_NOT_PRESENT, |
| Sunny Srivastava | 84c3d23 | 2025-09-03 00:47:10 -0500 | [diff] [blame] | 67 | "Presence pin read successfully but device was absent."}, |
| Sunny Srivastava | ad7e25e | 2025-09-04 09:43:21 -0500 | [diff] [blame] | 68 | {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."}, |
| Rekha Aparna | 41f47e7 | 2025-09-18 01:44:09 -0500 | [diff] [blame] | 69 | {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."}, |
| 70 | {error_code::ERROR_PROCESSING_SYSTEM_CMD, |
| Souvik Roy | d7c7cb5 | 2025-07-30 06:31:02 +0000 | [diff] [blame] | 71 | "Error while executing system command tag."}, |
| Rekha Aparna | 7d9a706 | 2025-10-07 04:14:42 -0500 | [diff] [blame] | 72 | {error_code::KEYWORD_NOT_FOUND, "Keyword not found"}, |
| Rekha Aparna | 17ddfb5 | 2025-10-09 20:45:53 -0500 | [diff] [blame] | 73 | {error_code::OUT_OF_BOUND_EXCEPTION, "Out of bound error"}, |
| Souvik Roy | d7c7cb5 | 2025-07-30 06:31:02 +0000 | [diff] [blame] | 74 | {error_code::UNSUPPORTED_VPD_TYPE, "This VPD type is not supported"}, |
| Rekha Aparna | 7f6cd4c | 2025-10-06 23:44:04 -0500 | [diff] [blame] | 75 | {error_code::STANDARD_EXCEPTION, "Standard Exception thrown"}, |
| Rekha Aparna | 6256db9 | 2025-10-17 09:58:49 -0500 | [diff] [blame] | 76 | {error_code::FILE_SYSTEM_ERROR, "File system error."}, |
| 77 | {error_code::FAILED_TO_DETECT_LOCATION_CODE_TYPE, |
| 78 | "Failed to detect location code type"}, |
| 79 | {error_code::DBUS_FAILURE, "Dbus call failed"}, |
| 80 | {error_code::RECEIVED_INVALID_KWD_TYPE_FROM_DBUS, |
| 81 | "Received invalid keyword data type from DBus."}}; |
| Rekha Aparna | 5e3ff85 | 2025-08-12 10:51:23 -0500 | [diff] [blame] | 82 | } // namespace vpd |