xref: /openbmc/openpower-vpd-parser/vpd-manager/include/error_codes.hpp (revision 017567ad69b40820998c373ea82a01f8ec48af09)
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;
205e3ff854SRekha Aparna 
215e3ff854SRekha Aparna // Generic errors.
22*017567adSRekha Aparna static constexpr auto INVALID_INPUT_PARAMETER = 3001;
239443af22SRekha Aparna 
249443af22SRekha Aparna const std::unordered_map<int, std::string> errorCodeMap = {
259443af22SRekha Aparna     {FILE_NOT_FOUND, "File does not exist."},
269443af22SRekha Aparna     {FILE_ACCESS_ERROR, "Failed to access the file."},
279443af22SRekha Aparna     {EMPTY_FILE, "Empty file."},
289443af22SRekha Aparna     {INVALID_JSON, "Either JSON is missing FRU tag or invalid JSON object."},
299443af22SRekha Aparna     {MISSING_FLAG, "JSON is missing the flag to procees for the FRU."},
309443af22SRekha Aparna     {MISSING_ACTION_TAG,
319443af22SRekha Aparna      "JSON is missing the action tag to be performed for the FRU."},
329443af22SRekha Aparna     {FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
33*017567adSRekha Aparna     {INVALID_INPUT_PARAMETER,
349443af22SRekha Aparna      "Either one of the input parameter is invalid or empty."}};
355e3ff854SRekha Aparna } // namespace error_code
365e3ff854SRekha Aparna } // namespace vpd
37