xref: /openbmc/openpower-vpd-parser/vpd-manager/include/error_codes.hpp (revision 41f47e77ce0904f17ee5849af178e2fe23cdb28b)
15e3ff854SRekha Aparna #pragma once
25e3ff854SRekha Aparna 
39443af22SRekha Aparna #include <string>
49443af22SRekha Aparna #include <unordered_map>
59443af22SRekha Aparna 
65e3ff854SRekha Aparna namespace vpd
75e3ff854SRekha Aparna {
8ad7e25e9SSunny Srivastava enum error_code
95e3ff854SRekha Aparna {
105e3ff854SRekha Aparna     // File exceptions
11ad7e25e9SSunny Srivastava     FILE_NOT_FOUND = 2001, /*Just a random value*/
12ad7e25e9SSunny Srivastava     FILE_ACCESS_ERROR,
13ad7e25e9SSunny Srivastava     EMPTY_FILE,
145e3ff854SRekha Aparna 
155e3ff854SRekha Aparna     // JSON exceptions
16ad7e25e9SSunny Srivastava     INVALID_JSON,
17ad7e25e9SSunny Srivastava     MISSING_FLAG,
18ad7e25e9SSunny Srivastava     MISSING_ACTION_TAG,
19ad7e25e9SSunny Srivastava     FRU_PATH_NOT_FOUND,
20ad7e25e9SSunny Srivastava     JSON_PARSE_ERROR,
21ad7e25e9SSunny Srivastava     JSON_MISSING_GPIO_INFO,
22e0d24c0cSRekha Aparna     JSON_MISSING_SERVICE_NAME,
232d6f071aSRekha Aparna     REDUNDANT_PATH_NOT_FOUND,
242d6f071aSRekha Aparna     ERROR_GETTING_REDUNDANT_PATH,
252d6f071aSRekha Aparna     NO_EEPROM_PATH,
265e3ff854SRekha Aparna 
275e3ff854SRekha Aparna     // Generic errors.
28ad7e25e9SSunny Srivastava     INVALID_INPUT_PARAMETER,
29ad7e25e9SSunny Srivastava     DEVICE_NOT_PRESENT,
30ad7e25e9SSunny Srivastava     DEVICE_PRESENCE_UNKNOWN,
31*41f47e77SRekha Aparna     GPIO_LINE_EXCEPTION,
32*41f47e77SRekha Aparna     ERROR_PROCESSING_SYSTEM_CMD
33ad7e25e9SSunny Srivastava };
349443af22SRekha Aparna 
359443af22SRekha Aparna const std::unordered_map<int, std::string> errorCodeMap = {
36ad7e25e9SSunny Srivastava     {error_code::FILE_NOT_FOUND, "File does not exist."},
37ad7e25e9SSunny Srivastava     {error_code::FILE_ACCESS_ERROR, "Failed to access the file."},
38ad7e25e9SSunny Srivastava     {error_code::EMPTY_FILE, "Empty file."},
39ad7e25e9SSunny Srivastava     {error_code::INVALID_JSON,
40ad7e25e9SSunny Srivastava      "Either JSON is missing FRU tag or invalid JSON object."},
41ad7e25e9SSunny Srivastava     {error_code::MISSING_FLAG,
42ad7e25e9SSunny Srivastava      "JSON is missing the flag to procees for the FRU."},
43ad7e25e9SSunny Srivastava     {error_code::MISSING_ACTION_TAG,
449443af22SRekha Aparna      "JSON is missing the action tag to be performed for the FRU."},
45ad7e25e9SSunny Srivastava     {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
46ad7e25e9SSunny Srivastava     {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."},
47ad7e25e9SSunny Srivastava     {error_code::INVALID_INPUT_PARAMETER,
4884c3d23fSSunny Srivastava      "Either one of the input parameter is invalid or empty."},
49ad7e25e9SSunny Srivastava     {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."},
50e0d24c0cSRekha Aparna     {error_code::JSON_MISSING_SERVICE_NAME,
51e0d24c0cSRekha Aparna      "JSON missing the service name for the FRU"},
522d6f071aSRekha Aparna     {error_code::REDUNDANT_PATH_NOT_FOUND, "No redundant path for the FRU."},
532d6f071aSRekha Aparna     {error_code::ERROR_GETTING_REDUNDANT_PATH,
542d6f071aSRekha Aparna      "Error while trying to get redundant path for the FRU"},
552d6f071aSRekha Aparna     {error_code::NO_EEPROM_PATH, "EEPROM path not found."},
56ad7e25e9SSunny Srivastava     {error_code::DEVICE_NOT_PRESENT,
5784c3d23fSSunny Srivastava      "Presence pin read successfully but device was absent."},
58ad7e25e9SSunny Srivastava     {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."},
59*41f47e77SRekha Aparna     {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."},
60*41f47e77SRekha Aparna     {error_code::ERROR_PROCESSING_SYSTEM_CMD,
61*41f47e77SRekha Aparna      "Error while executing system command tag."}};
625e3ff854SRekha Aparna } // namespace vpd
63