blob: 60a14921bc2f93ce396fa2946dfc8acec0130aab [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{
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -05008enum error_code
Rekha Aparna5e3ff852025-08-12 10:51:23 -05009{
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050010 // File exceptions
11 FILE_NOT_FOUND = 2001, /*Just a random value*/
12 FILE_ACCESS_ERROR,
13 EMPTY_FILE,
Rekha Aparna5e3ff852025-08-12 10:51:23 -050014
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050015 // JSON exceptions
16 INVALID_JSON,
17 MISSING_FLAG,
18 MISSING_ACTION_TAG,
19 FRU_PATH_NOT_FOUND,
20 JSON_PARSE_ERROR,
21 JSON_MISSING_GPIO_INFO,
Rekha Aparnae0d24c02025-09-02 00:15:06 -050022 JSON_MISSING_SERVICE_NAME,
Rekha Aparna5e3ff852025-08-12 10:51:23 -050023
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050024 // Generic errors.
25 INVALID_INPUT_PARAMETER,
26 DEVICE_NOT_PRESENT,
27 DEVICE_PRESENCE_UNKNOWN,
28 GPIO_LINE_EXCEPTION
29};
Rekha Aparna9443af22025-08-28 02:40:08 -050030
31const std::unordered_map<int, std::string> errorCodeMap = {
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050032 {error_code::FILE_NOT_FOUND, "File does not exist."},
33 {error_code::FILE_ACCESS_ERROR, "Failed to access the file."},
34 {error_code::EMPTY_FILE, "Empty file."},
35 {error_code::INVALID_JSON,
36 "Either JSON is missing FRU tag or invalid JSON object."},
37 {error_code::MISSING_FLAG,
38 "JSON is missing the flag to procees for the FRU."},
39 {error_code::MISSING_ACTION_TAG,
Rekha Aparna9443af22025-08-28 02:40:08 -050040 "JSON is missing the action tag to be performed for the FRU."},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050041 {error_code::FRU_PATH_NOT_FOUND, "The FRU path is not found in the JSON."},
42 {error_code::JSON_PARSE_ERROR, "Error while parsing JSON file."},
43 {error_code::INVALID_INPUT_PARAMETER,
Sunny Srivastava84c3d232025-09-03 00:47:10 -050044 "Either one of the input parameter is invalid or empty."},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050045 {error_code::JSON_MISSING_GPIO_INFO, "JSON missing required GPIO info."},
Rekha Aparnae0d24c02025-09-02 00:15:06 -050046 {error_code::JSON_MISSING_SERVICE_NAME,
47 "JSON missing the service name for the FRU"},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050048 {error_code::DEVICE_NOT_PRESENT,
Sunny Srivastava84c3d232025-09-03 00:47:10 -050049 "Presence pin read successfully but device was absent."},
Sunny Srivastavaad7e25e2025-09-04 09:43:21 -050050 {error_code::DEVICE_PRESENCE_UNKNOWN, "Exception on presence line GPIO."},
51 {error_code::GPIO_LINE_EXCEPTION, "There was an exception in GPIO line."}};
Rekha Aparna5e3ff852025-08-12 10:51:23 -050052} // namespace vpd