blob: 0ac08aa806f71f9a714847235752a64d94f7639c [file] [log] [blame]
Rekha Aparna5e3ff852025-08-12 10:51:23 -05001#pragma once
2
Rekha Aparna9443af22025-08-28 02:40:08 -05003#include <string>
4#include <unordered_map>
5
Rekha Aparna5e3ff852025-08-12 10:51:23 -05006namespace vpd
7{
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -05008enum error_code
Rekha Aparna5e3ff852025-08-12 10:51:23 -05009{
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050010 // File exceptions
11 FILE_NOT_FOUND = 2001, /*Just a random value*/
12 FILE_ACCESS_ERROR,
13 EMPTY_FILE,
Rekha Aparna7f6cd4c2025-10-06 23:44:04 -050014 FILE_SYSTEM_ERROR,
Rekha Aparna5e3ff852025-08-12 10:51:23 -050015
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050016 // 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 Aparnae0d24c02025-09-02 00:15:06 -050023 JSON_MISSING_SERVICE_NAME,
Rekha Aparna2d6f0712025-09-02 03:52:57 -050024 REDUNDANT_PATH_NOT_FOUND,
25 ERROR_GETTING_REDUNDANT_PATH,
26 NO_EEPROM_PATH,
Rekha Aparna5e3ff852025-08-12 10:51:23 -050027
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050028 // Generic errors.
29 INVALID_INPUT_PARAMETER,
30 DEVICE_NOT_PRESENT,
31 DEVICE_PRESENCE_UNKNOWN,
Rekha Aparna41f47e72025-09-18 01:44:09 -050032 GPIO_LINE_EXCEPTION,
Souvik Royd7c7cb52025-07-30 06:31:02 +000033 ERROR_PROCESSING_SYSTEM_CMD,
34 STANDARD_EXCEPTION,
35
36 // VPD specific errors
Rekha Aparna7d9a7062025-10-07 04:14:42 -050037 UNSUPPORTED_VPD_TYPE,
38 KEYWORD_NOT_FOUND
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050039};
Rekha Aparna9443af22025-08-28 02:40:08 -050040
41const std::unordered_map<int, std::string> errorCodeMap = {
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050042 {error_code::FILE_NOT_FOUND, "File does not exist."},
43 {error_code::FILE_ACCESS_ERROR, "Failed to access the file."},
44 {error_code::EMPTY_FILE, "Empty file."},
45 {error_code::INVALID_JSON,
46 "Either JSON is missing FRU tag or invalid JSON object."},
47 {error_code::MISSING_FLAG,
48 "JSON is missing the flag to procees for the FRU."},
49 {error_code::MISSING_ACTION_TAG,
Rekha Aparna9443af22025-08-28 02:40:08 -050050 "JSON is missing the action tag to be performed for the FRU."},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050051 {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
52 {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."},
53 {error_code::INVALID_INPUT_PARAMETER,
Sunny Srivastava84c3d232025-09-03 00:47:10 -050054 "Either one of the input parameter is invalid or empty."},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050055 {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."},
Rekha Aparnae0d24c02025-09-02 00:15:06 -050056 {error_code::JSON_MISSING_SERVICE_NAME,
57 "JSON missing the service name for the FRU"},
Rekha Aparna2d6f0712025-09-02 03:52:57 -050058 {error_code::REDUNDANT_PATH_NOT_FOUND, "No redundant path for the FRU."},
59 {error_code::ERROR_GETTING_REDUNDANT_PATH,
60 "Error while trying to get redundant path for the FRU"},
61 {error_code::NO_EEPROM_PATH, "EEPROM path not found."},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050062 {error_code::DEVICE_NOT_PRESENT,
Sunny Srivastava84c3d232025-09-03 00:47:10 -050063 "Presence pin read successfully but device was absent."},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050064 {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."},
Rekha Aparna41f47e72025-09-18 01:44:09 -050065 {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."},
66 {error_code::ERROR_PROCESSING_SYSTEM_CMD,
Souvik Royd7c7cb52025-07-30 06:31:02 +000067 "Error while executing system command tag."},
Rekha Aparna7d9a7062025-10-07 04:14:42 -050068 {error_code::KEYWORD_NOT_FOUND, "Keyword not found"},
Souvik Royd7c7cb52025-07-30 06:31:02 +000069 {error_code::UNSUPPORTED_VPD_TYPE, "This VPD type is not supported"},
Rekha Aparna7f6cd4c2025-10-06 23:44:04 -050070 {error_code::STANDARD_EXCEPTION, "Standard Exception thrown"},
71 {error_code::FILE_SYSTEM_ERROR, "File system error."}};
Rekha Aparna5e3ff852025-08-12 10:51:23 -050072} // namespace vpd