blob: ad436c4b09b02f8283df214962fa38566c495470 [file] [log] [blame]
Rekha Aparna5e3ff852025-08-12 10:51:23 -05001#pragma once
2
Rekha Aparna9443af22025-08-28 02:40:08 -05003#include <string>
4#include <unordered_map>
5
Rekha Aparna5e3ff852025-08-12 10:51:23 -05006namespace vpd
7{
8namespace error_code
9{
10// File exceptions
11static constexpr auto FILE_NOT_FOUND = 1001;
12static constexpr auto FILE_ACCESS_ERROR = 1002;
13static constexpr auto EMPTY_FILE = 1003;
14
15// JSON exceptions
16static constexpr auto INVALID_JSON = 2001;
17static constexpr auto MISSING_FLAG = 2002;
18static constexpr auto MISSING_ACTION_TAG = 2003;
19static constexpr auto FRU_PATH_NOT_FOUND = 2004;
Rekha Aparnaca9a0862025-08-29 04:08:33 -050020static constexpr auto JSON_PARSE_ERROR = 2005;
Rekha Aparna5e3ff852025-08-12 10:51:23 -050021
22// Generic errors.
Rekha Aparna017567a2025-08-13 02:07:06 -050023static constexpr auto INVALID_INPUT_PARAMETER = 3001;
Rekha Aparna9443af22025-08-28 02:40:08 -050024
25const 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."},
Rekha Aparnaca9a0862025-08-29 04:08:33 -050034 {JSON_PARSE_ERROR, "Error while parsing JSON file."},
Rekha Aparna017567a2025-08-13 02:07:06 -050035 {INVALID_INPUT_PARAMETER,
Rekha Aparna9443af22025-08-28 02:40:08 -050036 "Either one of the input parameter is invalid or empty."}};
Rekha Aparna5e3ff852025-08-12 10:51:23 -050037} // namespace error_code
38} // namespace vpd