xref: /openbmc/openpower-vpd-parser/vpd-manager/include/error_codes.hpp (revision ca9a08665677fbd0b97654318805a6c92bb12ef8)
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;
20*ca9a0866SRekha Aparna static constexpr auto JSON_PARSE_ERROR = 2005;
215e3ff854SRekha Aparna 
225e3ff854SRekha Aparna // Generic errors.
23017567adSRekha Aparna static constexpr auto INVALID_INPUT_PARAMETER = 3001;
249443af22SRekha Aparna 
259443af22SRekha Aparna const std::unordered_map<int, std::string> errorCodeMap = {
269443af22SRekha Aparna     {FILE_NOT_FOUND, "File does not exist."},
279443af22SRekha Aparna     {FILE_ACCESS_ERROR, "Failed to access the file."},
289443af22SRekha Aparna     {EMPTY_FILE, "Empty file."},
299443af22SRekha Aparna     {INVALID_JSON, "Either JSON is missing FRU tag or invalid JSON object."},
309443af22SRekha Aparna     {MISSING_FLAG, "JSON is missing the flag to procees for the FRU."},
319443af22SRekha Aparna     {MISSING_ACTION_TAG,
329443af22SRekha Aparna      "JSON is missing the action tag to be performed for the FRU."},
339443af22SRekha Aparna     {FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
34*ca9a0866SRekha Aparna     {JSON_PARSE_ERROR, "Error while parsing JSON file."},
35017567adSRekha Aparna     {INVALID_INPUT_PARAMETER,
369443af22SRekha Aparna      "Either one of the input parameter is invalid or empty."}};
375e3ff854SRekha Aparna } // namespace error_code
385e3ff854SRekha Aparna } // namespace vpd
39