xref: /openbmc/openpower-vpd-parser/vpd-manager/include/error_codes.hpp (revision 0cdf9dd9a447e602d72426dcf00cf9aec937ea5d)
1 #pragma once
2 
3 #include <string>
4 #include <unordered_map>
5 
6 namespace vpd
7 {
8 enum error_code
9 {
10     // File exceptions
11     FILE_NOT_FOUND = 2001, /*Just a random value*/
12     FILE_ACCESS_ERROR,
13     EMPTY_FILE,
14     FILE_SYSTEM_ERROR,
15 
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,
23     JSON_MISSING_SERVICE_NAME,
24     REDUNDANT_PATH_NOT_FOUND,
25     ERROR_GETTING_REDUNDANT_PATH,
26     NO_EEPROM_PATH,
27 
28     // Generic errors.
29     INVALID_INPUT_PARAMETER,
30     DEVICE_NOT_PRESENT,
31     DEVICE_PRESENCE_UNKNOWN,
32     GPIO_LINE_EXCEPTION,
33     ERROR_PROCESSING_SYSTEM_CMD,
34     STANDARD_EXCEPTION,
35     DBUS_FAILURE,
36     POPEN_FAILED,
37     INVALID_HEXADECIMAL_VALUE_LENGTH,
38     INVALID_HEXADECIMAL_VALUE,
39     INVALID_INVENTORY_PATH,
40 
41     // VPD specific errors
42     UNSUPPORTED_VPD_TYPE,
43     KEYWORD_NOT_FOUND,
44     OUT_OF_BOUND_EXCEPTION,
45     FAILED_TO_DETECT_LOCATION_CODE_TYPE,
46     RECEIVED_INVALID_KWD_TYPE_FROM_DBUS,
47     INVALID_KEYWORD_LENGTH,
48     INVALID_VALUE_READ_FROM_DBUS,
49     RECORD_NOT_FOUND
50 };
51 
52 const std::unordered_map<int, std::string> errorCodeMap = {
53     {error_code::FILE_NOT_FOUND, "File does not exist."},
54     {error_code::FILE_ACCESS_ERROR, "Failed to access the file."},
55     {error_code::EMPTY_FILE, "Empty file."},
56     {error_code::INVALID_JSON,
57      "Either JSON is missing FRU tag or invalid JSON object."},
58     {error_code::MISSING_FLAG,
59      "JSON is missing the flag to procees for the FRU."},
60     {error_code::MISSING_ACTION_TAG,
61      "JSON is missing the action tag to be performed for the FRU."},
62     {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
63     {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."},
64     {error_code::INVALID_INPUT_PARAMETER,
65      "Either one of the input parameter is invalid or empty."},
66     {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."},
67     {error_code::JSON_MISSING_SERVICE_NAME,
68      "JSON missing the service name for the FRU"},
69     {error_code::REDUNDANT_PATH_NOT_FOUND, "No redundant path for the FRU."},
70     {error_code::ERROR_GETTING_REDUNDANT_PATH,
71      "Error while trying to get redundant path for the FRU"},
72     {error_code::NO_EEPROM_PATH, "EEPROM path not found."},
73     {error_code::DEVICE_NOT_PRESENT,
74      "Presence pin read successfully but device was absent."},
75     {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."},
76     {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."},
77     {error_code::ERROR_PROCESSING_SYSTEM_CMD,
78      "Error while executing system command tag."},
79     {error_code::KEYWORD_NOT_FOUND, "Keyword not found"},
80     {error_code::OUT_OF_BOUND_EXCEPTION, "Out of bound error"},
81     {error_code::UNSUPPORTED_VPD_TYPE, "This VPD type is not supported"},
82     {error_code::STANDARD_EXCEPTION, "Standard Exception thrown"},
83     {error_code::FILE_SYSTEM_ERROR, "File system error."},
84     {error_code::INVALID_KEYWORD_LENGTH, "Invalid keyword length."},
85     {error_code::INVALID_VALUE_READ_FROM_DBUS, "Invalid value read from DBus"},
86     {error_code::RECORD_NOT_FOUND, "Record not found."},
87     {error_code::FAILED_TO_DETECT_LOCATION_CODE_TYPE,
88      "Failed to detect location code type"},
89     {error_code::DBUS_FAILURE, "Dbus call failed"},
90     {error_code::RECEIVED_INVALID_KWD_TYPE_FROM_DBUS,
91      "Received invalid keyword data type from DBus."},
92     {error_code::POPEN_FAILED, "popen failed"},
93     {error_code::INVALID_HEXADECIMAL_VALUE_LENGTH,
94      "Invalid hexadecimal value length."},
95     {error_code::INVALID_HEXADECIMAL_VALUE, "Invalid hexadecimal value."},
96     {error_code::INVALID_INVENTORY_PATH, "Invalid inventory path."}};
97 } // namespace vpd
98