xref: /openbmc/openpower-vpd-parser/vpd-manager/include/error_codes.hpp (revision 84c3d23f9bf584a8363d55b1e300b3e7f9fb352c)
15e3ff854SRekha Aparna #pragma once
25e3ff854SRekha Aparna 
39443af22SRekha Aparna #include <string>
49443af22SRekha Aparna #include <unordered_map>
59443af22SRekha Aparna 
65e3ff854SRekha Aparna namespace vpd
75e3ff854SRekha Aparna {
85e3ff854SRekha Aparna namespace error_code
95e3ff854SRekha Aparna {
105e3ff854SRekha Aparna // File exceptions
115e3ff854SRekha Aparna static constexpr auto FILE_NOT_FOUND = 1001;
125e3ff854SRekha Aparna static constexpr auto FILE_ACCESS_ERROR = 1002;
135e3ff854SRekha Aparna static constexpr auto EMPTY_FILE = 1003;
145e3ff854SRekha Aparna 
155e3ff854SRekha Aparna // JSON exceptions
165e3ff854SRekha Aparna static constexpr auto INVALID_JSON = 2001;
175e3ff854SRekha Aparna static constexpr auto MISSING_FLAG = 2002;
185e3ff854SRekha Aparna static constexpr auto MISSING_ACTION_TAG = 2003;
195e3ff854SRekha Aparna static constexpr auto FRU_PATH_NOT_FOUND = 2004;
20ca9a0866SRekha Aparna static constexpr auto JSON_PARSE_ERROR = 2005;
21*84c3d23fSSunny Srivastava static constexpr auto JSON_MISSING_GPIO_INFO = 2006;
225e3ff854SRekha Aparna 
235e3ff854SRekha Aparna // Generic errors.
24017567adSRekha Aparna static constexpr auto INVALID_INPUT_PARAMETER = 3001;
25*84c3d23fSSunny Srivastava static constexpr auto DEVICE_NOT_PRESENT = 2006;
26*84c3d23fSSunny Srivastava static constexpr auto DEVICE_PRESENCE_UNKNOWN = 2007;
27*84c3d23fSSunny Srivastava static constexpr auto GPIO_LINE_EXCEPTION = 2008;
289443af22SRekha Aparna 
299443af22SRekha Aparna const std::unordered_map<int, std::string> errorCodeMap = {
309443af22SRekha Aparna     {FILE_NOT_FOUND, "File does not exist."},
319443af22SRekha Aparna     {FILE_ACCESS_ERROR, "Failed to access the file."},
329443af22SRekha Aparna     {EMPTY_FILE, "Empty file."},
339443af22SRekha Aparna     {INVALID_JSON, "Either JSON is missing FRU tag or invalid JSON object."},
349443af22SRekha Aparna     {MISSING_FLAG, "JSON is missing the flag to procees for the FRU."},
359443af22SRekha Aparna     {MISSING_ACTION_TAG,
369443af22SRekha Aparna      "JSON is missing the action tag to be performed for the FRU."},
379443af22SRekha Aparna     {FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
38ca9a0866SRekha Aparna     {JSON_PARSE_ERROR, "Error while parsing JSON file."},
39017567adSRekha Aparna     {INVALID_INPUT_PARAMETER,
40*84c3d23fSSunny Srivastava      "Either one of the input parameter is invalid or empty."},
41*84c3d23fSSunny Srivastava     {JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."},
42*84c3d23fSSunny Srivastava     {DEVICE_NOT_PRESENT,
43*84c3d23fSSunny Srivastava      "Presence pin read successfully but device was absent."},
44*84c3d23fSSunny Srivastava     {DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."},
45*84c3d23fSSunny Srivastava     {GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."}};
465e3ff854SRekha Aparna } // namespace error_code
475e3ff854SRekha Aparna } // namespace vpd
48