15e3ff854SRekha Aparna #pragma once 25e3ff854SRekha Aparna 39443af22SRekha Aparna #include <string> 49443af22SRekha Aparna #include <unordered_map> 59443af22SRekha Aparna 65e3ff854SRekha Aparna namespace vpd 75e3ff854SRekha Aparna { 8*ad7e25e9SSunny Srivastava enum error_code 95e3ff854SRekha Aparna { 105e3ff854SRekha Aparna // File exceptions 11*ad7e25e9SSunny Srivastava FILE_NOT_FOUND = 2001, /*Just a random value*/ 12*ad7e25e9SSunny Srivastava FILE_ACCESS_ERROR, 13*ad7e25e9SSunny Srivastava EMPTY_FILE, 145e3ff854SRekha Aparna 155e3ff854SRekha Aparna // JSON exceptions 16*ad7e25e9SSunny Srivastava INVALID_JSON, 17*ad7e25e9SSunny Srivastava MISSING_FLAG, 18*ad7e25e9SSunny Srivastava MISSING_ACTION_TAG, 19*ad7e25e9SSunny Srivastava FRU_PATH_NOT_FOUND, 20*ad7e25e9SSunny Srivastava JSON_PARSE_ERROR, 21*ad7e25e9SSunny Srivastava JSON_MISSING_GPIO_INFO, 225e3ff854SRekha Aparna 235e3ff854SRekha Aparna // Generic errors. 24*ad7e25e9SSunny Srivastava INVALID_INPUT_PARAMETER, 25*ad7e25e9SSunny Srivastava DEVICE_NOT_PRESENT, 26*ad7e25e9SSunny Srivastava DEVICE_PRESENCE_UNKNOWN, 27*ad7e25e9SSunny Srivastava GPIO_LINE_EXCEPTION 28*ad7e25e9SSunny Srivastava }; 299443af22SRekha Aparna 309443af22SRekha Aparna const std::unordered_map<int, std::string> errorCodeMap = { 31*ad7e25e9SSunny Srivastava {error_code::FILE_NOT_FOUND, "File does not exist."}, 32*ad7e25e9SSunny Srivastava {error_code::FILE_ACCESS_ERROR, "Failed to access the file."}, 33*ad7e25e9SSunny Srivastava {error_code::EMPTY_FILE, "Empty file."}, 34*ad7e25e9SSunny Srivastava {error_code::INVALID_JSON, 35*ad7e25e9SSunny Srivastava "Either JSON is missing FRU tag or invalid JSON object."}, 36*ad7e25e9SSunny Srivastava {error_code::MISSING_FLAG, 37*ad7e25e9SSunny Srivastava "JSON is missing the flag to procees for the FRU."}, 38*ad7e25e9SSunny Srivastava {error_code::MISSING_ACTION_TAG, 399443af22SRekha Aparna "JSON is missing the action tag to be performed for the FRU."}, 40*ad7e25e9SSunny Srivastava {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."}, 41*ad7e25e9SSunny Srivastava {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."}, 42*ad7e25e9SSunny Srivastava {error_code::INVALID_INPUT_PARAMETER, 4384c3d23fSSunny Srivastava "Either one of the input parameter is invalid or empty."}, 44*ad7e25e9SSunny Srivastava {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."}, 45*ad7e25e9SSunny Srivastava {error_code::DEVICE_NOT_PRESENT, 4684c3d23fSSunny Srivastava "Presence pin read successfully but device was absent."}, 47*ad7e25e9SSunny Srivastava {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."}, 48*ad7e25e9SSunny Srivastava {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."}}; 495e3ff854SRekha Aparna } // namespace vpd 50