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 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, 22 JSON_MISSING_SERVICE_NAME, 23 REDUNDANT_PATH_NOT_FOUND, 24 ERROR_GETTING_REDUNDANT_PATH, 25 NO_EEPROM_PATH, 26 27 // Generic errors. 28 INVALID_INPUT_PARAMETER, 29 DEVICE_NOT_PRESENT, 30 DEVICE_PRESENCE_UNKNOWN, 31 GPIO_LINE_EXCEPTION, 32 ERROR_PROCESSING_SYSTEM_CMD, 33 STANDARD_EXCEPTION, 34 35 // VPD specific errors 36 UNSUPPORTED_VPD_TYPE 37 }; 38 39 const std::unordered_map<int, std::string> errorCodeMap = { 40 {error_code::FILE_NOT_FOUND, "File does not exist."}, 41 {error_code::FILE_ACCESS_ERROR, "Failed to access the file."}, 42 {error_code::EMPTY_FILE, "Empty file."}, 43 {error_code::INVALID_JSON, 44 "Either JSON is missing FRU tag or invalid JSON object."}, 45 {error_code::MISSING_FLAG, 46 "JSON is missing the flag to procees for the FRU."}, 47 {error_code::MISSING_ACTION_TAG, 48 "JSON is missing the action tag to be performed for the FRU."}, 49 {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."}, 50 {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."}, 51 {error_code::INVALID_INPUT_PARAMETER, 52 "Either one of the input parameter is invalid or empty."}, 53 {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."}, 54 {error_code::JSON_MISSING_SERVICE_NAME, 55 "JSON missing the service name for the FRU"}, 56 {error_code::REDUNDANT_PATH_NOT_FOUND, "No redundant path for the FRU."}, 57 {error_code::ERROR_GETTING_REDUNDANT_PATH, 58 "Error while trying to get redundant path for the FRU"}, 59 {error_code::NO_EEPROM_PATH, "EEPROM path not found."}, 60 {error_code::DEVICE_NOT_PRESENT, 61 "Presence pin read successfully but device was absent."}, 62 {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."}, 63 {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."}, 64 {error_code::ERROR_PROCESSING_SYSTEM_CMD, 65 "Error while executing system command tag."}, 66 {error_code::UNSUPPORTED_VPD_TYPE, "This VPD type is not supported"}, 67 {error_code::STANDARD_EXCEPTION, "Standard Exception thrown"}}; 68 } // namespace vpd 69