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, 22*e0d24c0cSRekha Aparna JSON_MISSING_SERVICE_NAME, 235e3ff854SRekha Aparna 245e3ff854SRekha Aparna // Generic errors. 25ad7e25e9SSunny Srivastava INVALID_INPUT_PARAMETER, 26ad7e25e9SSunny Srivastava DEVICE_NOT_PRESENT, 27ad7e25e9SSunny Srivastava DEVICE_PRESENCE_UNKNOWN, 28ad7e25e9SSunny Srivastava GPIO_LINE_EXCEPTION 29ad7e25e9SSunny Srivastava }; 309443af22SRekha Aparna 319443af22SRekha Aparna const std::unordered_map<int, std::string> errorCodeMap = { 32ad7e25e9SSunny Srivastava {error_code::FILE_NOT_FOUND, "File does not exist."}, 33ad7e25e9SSunny Srivastava {error_code::FILE_ACCESS_ERROR, "Failed to access the file."}, 34ad7e25e9SSunny Srivastava {error_code::EMPTY_FILE, "Empty file."}, 35ad7e25e9SSunny Srivastava {error_code::INVALID_JSON, 36ad7e25e9SSunny Srivastava "Either JSON is missing FRU tag or invalid JSON object."}, 37ad7e25e9SSunny Srivastava {error_code::MISSING_FLAG, 38ad7e25e9SSunny Srivastava "JSON is missing the flag to procees for the FRU."}, 39ad7e25e9SSunny Srivastava {error_code::MISSING_ACTION_TAG, 409443af22SRekha Aparna "JSON is missing the action tag to be performed for the FRU."}, 41ad7e25e9SSunny Srivastava {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."}, 42ad7e25e9SSunny Srivastava {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."}, 43ad7e25e9SSunny Srivastava {error_code::INVALID_INPUT_PARAMETER, 4484c3d23fSSunny Srivastava "Either one of the input parameter is invalid or empty."}, 45ad7e25e9SSunny Srivastava {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."}, 46*e0d24c0cSRekha Aparna {error_code::JSON_MISSING_SERVICE_NAME, 47*e0d24c0cSRekha Aparna "JSON missing the service name for the FRU"}, 48ad7e25e9SSunny Srivastava {error_code::DEVICE_NOT_PRESENT, 4984c3d23fSSunny Srivastava "Presence pin read successfully but device was absent."}, 50ad7e25e9SSunny Srivastava {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."}, 51ad7e25e9SSunny Srivastava {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."}}; 525e3ff854SRekha Aparna } // namespace vpd 53