xref: /openbmc/openpower-vpd-parser/vpd-manager/include/error_codes.hpp (revision ca9a08665677fbd0b97654318805a6c92bb12ef8)
1 #pragma once
2 
3 #include <string>
4 #include <unordered_map>
5 
6 namespace vpd
7 {
8 namespace error_code
9 {
10 // File exceptions
11 static constexpr auto FILE_NOT_FOUND = 1001;
12 static constexpr auto FILE_ACCESS_ERROR = 1002;
13 static constexpr auto EMPTY_FILE = 1003;
14 
15 // JSON exceptions
16 static constexpr auto INVALID_JSON = 2001;
17 static constexpr auto MISSING_FLAG = 2002;
18 static constexpr auto MISSING_ACTION_TAG = 2003;
19 static constexpr auto FRU_PATH_NOT_FOUND = 2004;
20 static constexpr auto JSON_PARSE_ERROR = 2005;
21 
22 // Generic errors.
23 static constexpr auto INVALID_INPUT_PARAMETER = 3001;
24 
25 const std::unordered_map<int, std::string> errorCodeMap = {
26     {FILE_NOT_FOUND, "File does not exist."},
27     {FILE_ACCESS_ERROR, "Failed to access the file."},
28     {EMPTY_FILE, "Empty file."},
29     {INVALID_JSON, "Either JSON is missing FRU tag or invalid JSON object."},
30     {MISSING_FLAG, "JSON is missing the flag to procees for the FRU."},
31     {MISSING_ACTION_TAG,
32      "JSON is missing the action tag to be performed for the FRU."},
33     {FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
34     {JSON_PARSE_ERROR, "Error while parsing JSON file."},
35     {INVALID_INPUT_PARAMETER,
36      "Either one of the input parameter is invalid or empty."}};
37 } // namespace error_code
38 } // namespace vpd
39