@bniladridas/cursor 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.clang-tidy +28 -0
- package/.dockerignore +56 -0
- package/.env.example +29 -0
- package/.github/CODEOWNERS +2 -0
- package/.github/ISSUE_TEMPLATE/blank.md +27 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- package/.github/SECURITY.md +24 -0
- package/.github/codeql/codeql-config.yml +8 -0
- package/.github/dependabot.yml +14 -0
- package/.github/labeler.yml +50 -0
- package/.github/packaging/brand-cursor.png +0 -0
- package/.github/packaging/database/init.sql +48 -0
- package/.github/packaging/docker/Dockerfile +111 -0
- package/.github/packaging/docker/docker-compose.yml +56 -0
- package/.github/packaging/scripts/preflight.sh +413 -0
- package/.github/packaging/scripts/prepare-release.sh +141 -0
- package/.github/packaging/scripts/release.sh +22 -0
- package/.github/packaging/scripts/setup-git-hooks.sh +73 -0
- package/.github/pull_request_template.md +31 -0
- package/.github/signed.json +9 -0
- package/.github/workflows/README.md +23 -0
- package/.github/workflows/ci.yml +181 -0
- package/.github/workflows/cla.yml +33 -0
- package/.github/workflows/formula-sha.yml +63 -0
- package/.github/workflows/issue-response.yml +44 -0
- package/.github/workflows/labeler.yml +42 -0
- package/.github/workflows/pr-body.yml +49 -0
- package/.github/workflows/release.yml +176 -0
- package/.github/workflows/security.yml +94 -0
- package/.github/workflows/stale.yml +38 -0
- package/AGENTS.md +49 -0
- package/CHANGELOG.md +3 -0
- package/CMakeLists.txt +646 -0
- package/Formula/cursor.rb +46 -0
- package/LICENSE +201 -0
- package/Makefile +28 -0
- package/README.md +46 -0
- package/cli.js +16 -0
- package/include/agent.h +86 -0
- package/include/agent_mode.h +17 -0
- package/include/memory_manager.h +102 -0
- package/include/services/ai_service.h +31 -0
- package/include/services/auth_service.h +87 -0
- package/include/services/checkpoint_service.h +69 -0
- package/include/services/codebase_service.h +38 -0
- package/include/services/command_service.h +23 -0
- package/include/services/context_service.h +74 -0
- package/include/services/database_service.h +56 -0
- package/include/services/error_service.h +106 -0
- package/include/services/file_service.h +51 -0
- package/include/services/git_service.h +29 -0
- package/include/services/github_service.h +85 -0
- package/include/services/mcp_service.h +85 -0
- package/include/services/multi_file_service.h +93 -0
- package/include/services/sandbox_service.h +96 -0
- package/include/services/theme_service.h +67 -0
- package/include/services/web_service.h +52 -0
- package/include/utils/config.h +68 -0
- package/include/utils/memory_utils.h +79 -0
- package/include/utils/platform.h +56 -0
- package/include/utils/ui.h +43 -0
- package/include/utils/validation.h +63 -0
- package/include/utils/version.h.in +17 -0
- package/install.js +49 -0
- package/package.json +16 -0
- package/release/checksums.txt +3 -0
- package/release/cursor-linux/cursor_v0.1.7_linux_amd64.tar.gz +0 -0
- package/release/cursor-macos/cursor_v0.1.7_darwin_arm64.tar.gz +0 -0
- package/release/cursor-windows/cursor__windows_amd64.zip +0 -0
- package/src/agent.cpp +2026 -0
- package/src/main.cpp +97 -0
- package/src/memory_manager.cpp +814 -0
- package/src/services/ai_service.cpp +366 -0
- package/src/services/auth_service.cpp +779 -0
- package/src/services/checkpoint_service.cpp +465 -0
- package/src/services/codebase_service.cpp +233 -0
- package/src/services/command_service.cpp +82 -0
- package/src/services/context_service.cpp +348 -0
- package/src/services/database_service.cpp +148 -0
- package/src/services/error_service.cpp +438 -0
- package/src/services/file_service.cpp +349 -0
- package/src/services/git_service.cpp +148 -0
- package/src/services/github_service.cpp +435 -0
- package/src/services/mcp_service.cpp +481 -0
- package/src/services/multi_file_service.cpp +591 -0
- package/src/services/sandbox_service.cpp +678 -0
- package/src/services/theme_service.cpp +429 -0
- package/src/services/web_service.cpp +532 -0
- package/src/utils/config.cpp +77 -0
- package/src/utils/memory_utils.cpp +93 -0
- package/src/utils/ui.cpp +307 -0
- package/src/utils/validation.cpp +306 -0
- package/src/utils/version.cpp +175 -0
- package/tests/e2e/docker-compose.yml +195 -0
- package/tests/e2e/run_e2e_tests.sh +70 -0
- package/tests/e2e/run_tests_in_docker.sh +115 -0
- package/tests/main_test.cpp +16 -0
- package/tests/mocks/mock_ollama.py +98 -0
- package/tests/mocks/start_nginx.sh +64 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
#include "services/error_service.h"
|
|
2
|
+
#include <filesystem>
|
|
3
|
+
#include <fstream>
|
|
4
|
+
#include <iomanip>
|
|
5
|
+
#include <iostream>
|
|
6
|
+
#include <nlohmann/json.hpp>
|
|
7
|
+
#include <regex>
|
|
8
|
+
#include <sstream>
|
|
9
|
+
|
|
10
|
+
namespace Services {
|
|
11
|
+
|
|
12
|
+
std::vector<ErrorInfo> ErrorService::error_log;
|
|
13
|
+
std::map<std::string, ValidationRule> ErrorService::validation_rules;
|
|
14
|
+
|
|
15
|
+
std::string ErrorService::get_error_log_path() { return "data/error_log.json"; }
|
|
16
|
+
|
|
17
|
+
void ErrorService::ensure_error_directory() {
|
|
18
|
+
std::filesystem::create_directories("data");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
std::string ErrorService::generate_error_id() {
|
|
22
|
+
static int counter = 1;
|
|
23
|
+
auto now = std::chrono::system_clock::now();
|
|
24
|
+
auto time_t = std::chrono::system_clock::to_time_t(now);
|
|
25
|
+
|
|
26
|
+
std::stringstream ss;
|
|
27
|
+
ss << "ERR_" << std::put_time(std::localtime(&time_t), "%Y%m%d_%H%M%S") << "_"
|
|
28
|
+
<< std::setfill('0') << std::setw(3) << counter++;
|
|
29
|
+
|
|
30
|
+
return ss.str();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void ErrorService::initialize_validation_rules() {
|
|
34
|
+
// File path validation
|
|
35
|
+
validation_rules["file_path"] = {
|
|
36
|
+
"file_path",
|
|
37
|
+
[](const std::string &path) {
|
|
38
|
+
return !path.empty() && path.find("..") == std::string::npos &&
|
|
39
|
+
path.length() < 4096;
|
|
40
|
+
},
|
|
41
|
+
"Invalid file path",
|
|
42
|
+
{"Ensure path is not empty", "Avoid '..' in paths",
|
|
43
|
+
"Keep path under 4096 characters"}};
|
|
44
|
+
|
|
45
|
+
// URL validation
|
|
46
|
+
validation_rules["url"] = {
|
|
47
|
+
"url",
|
|
48
|
+
[](const std::string &url) {
|
|
49
|
+
std::regex url_regex(R"(^https?://[^\s/$.?#].[^\s]*$)");
|
|
50
|
+
return std::regex_match(url, url_regex);
|
|
51
|
+
},
|
|
52
|
+
"Invalid URL format",
|
|
53
|
+
{"Use http:// or https:// protocol", "Ensure no spaces in URL",
|
|
54
|
+
"Check domain format"}};
|
|
55
|
+
|
|
56
|
+
// Command validation
|
|
57
|
+
validation_rules["command"] = {
|
|
58
|
+
"command",
|
|
59
|
+
[](const std::string &command) {
|
|
60
|
+
// Basic command safety checks
|
|
61
|
+
std::vector<std::string> dangerous = {"rm -rf", "format", "del /f",
|
|
62
|
+
"sudo rm"};
|
|
63
|
+
for (const auto &danger : dangerous) {
|
|
64
|
+
if (command.find(danger) != std::string::npos) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return !command.empty() && command.length() < 1024;
|
|
69
|
+
},
|
|
70
|
+
"Potentially dangerous or invalid command",
|
|
71
|
+
{"Avoid destructive commands", "Keep commands under 1024 characters",
|
|
72
|
+
"Use safe alternatives"}};
|
|
73
|
+
|
|
74
|
+
// API key validation
|
|
75
|
+
validation_rules["api_key"] = {
|
|
76
|
+
"api_key",
|
|
77
|
+
[](const std::string &key) {
|
|
78
|
+
return !key.empty() && key.length() >= 10 && key.length() <= 512 &&
|
|
79
|
+
key.find(' ') == std::string::npos;
|
|
80
|
+
},
|
|
81
|
+
"Invalid API key format",
|
|
82
|
+
{"API key should be 10-512 characters", "No spaces allowed",
|
|
83
|
+
"Check with provider documentation"}};
|
|
84
|
+
|
|
85
|
+
// JSON validation
|
|
86
|
+
validation_rules["json"] = {
|
|
87
|
+
"json",
|
|
88
|
+
[](const std::string &json_str) {
|
|
89
|
+
try {
|
|
90
|
+
auto parsed = nlohmann::json::parse(json_str);
|
|
91
|
+
(void)parsed; // Suppress unused variable warning
|
|
92
|
+
return true;
|
|
93
|
+
} catch (...) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"Invalid JSON format",
|
|
98
|
+
{"Check bracket/brace matching", "Ensure proper quoting",
|
|
99
|
+
"Validate syntax"}};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void ErrorService::initialize() {
|
|
103
|
+
initialize_validation_rules();
|
|
104
|
+
load_error_config();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
std::string
|
|
108
|
+
ErrorService::log_error(ErrorLevel level, ErrorCategory category,
|
|
109
|
+
const std::string &message, const std::string &context,
|
|
110
|
+
const std::vector<std::string> &suggestions) {
|
|
111
|
+
ErrorInfo error;
|
|
112
|
+
error.id = generate_error_id();
|
|
113
|
+
error.level = level;
|
|
114
|
+
error.category = category;
|
|
115
|
+
error.message = message;
|
|
116
|
+
error.context = context;
|
|
117
|
+
error.timestamp = std::chrono::system_clock::now();
|
|
118
|
+
error.suggestions = suggestions;
|
|
119
|
+
|
|
120
|
+
error_log.push_back(error);
|
|
121
|
+
|
|
122
|
+
// Keep only recent errors (max 1000)
|
|
123
|
+
if (error_log.size() > 1000) {
|
|
124
|
+
error_log.erase(error_log.begin(), error_log.begin() + 100);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Print error to console based on level
|
|
128
|
+
if (level >= ErrorLevel::WARNING) {
|
|
129
|
+
std::cerr << format_error(error, true) << std::endl;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return error.id;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
std::vector<ErrorInfo> ErrorService::get_recent_errors(size_t count) {
|
|
136
|
+
std::vector<ErrorInfo> recent;
|
|
137
|
+
size_t start = error_log.size() > count ? error_log.size() - count : 0;
|
|
138
|
+
|
|
139
|
+
for (size_t i = start; i < error_log.size(); ++i) {
|
|
140
|
+
recent.push_back(error_log[i]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return recent;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
std::vector<ErrorInfo> ErrorService::get_errors_by_level(ErrorLevel level) {
|
|
147
|
+
std::vector<ErrorInfo> filtered;
|
|
148
|
+
for (const auto &error : error_log) {
|
|
149
|
+
if (error.level == level) {
|
|
150
|
+
filtered.push_back(error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return filtered;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
std::vector<ErrorInfo>
|
|
157
|
+
ErrorService::get_errors_by_category(ErrorCategory category) {
|
|
158
|
+
std::vector<ErrorInfo> filtered;
|
|
159
|
+
for (const auto &error : error_log) {
|
|
160
|
+
if (error.category == category) {
|
|
161
|
+
filtered.push_back(error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return filtered;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void ErrorService::clear_error_log() { error_log.clear(); }
|
|
168
|
+
|
|
169
|
+
bool ErrorService::validate_input(const std::string &rule_name,
|
|
170
|
+
const std::string &input,
|
|
171
|
+
std::string &error_message,
|
|
172
|
+
std::vector<std::string> &suggestions) {
|
|
173
|
+
auto it = validation_rules.find(rule_name);
|
|
174
|
+
if (it == validation_rules.end()) {
|
|
175
|
+
error_message = "Unknown validation rule: " + rule_name;
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const ValidationRule &rule = it->second;
|
|
180
|
+
if (!rule.validator(input)) {
|
|
181
|
+
error_message = rule.error_message;
|
|
182
|
+
suggestions = rule.suggestions;
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
bool ErrorService::validate_file_path(const std::string &path,
|
|
190
|
+
std::string &error_message) {
|
|
191
|
+
std::vector<std::string> suggestions;
|
|
192
|
+
return validate_input("file_path", path, error_message, suggestions);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
bool ErrorService::validate_url(const std::string &url,
|
|
196
|
+
std::string &error_message) {
|
|
197
|
+
std::vector<std::string> suggestions;
|
|
198
|
+
return validate_input("url", url, error_message, suggestions);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
bool ErrorService::validate_command(const std::string &command,
|
|
202
|
+
std::string &error_message) {
|
|
203
|
+
std::vector<std::string> suggestions;
|
|
204
|
+
return validate_input("command", command, error_message, suggestions);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
bool ErrorService::validate_api_key(const std::string &api_key,
|
|
208
|
+
std::string &error_message) {
|
|
209
|
+
std::vector<std::string> suggestions;
|
|
210
|
+
return validate_input("api_key", api_key, error_message, suggestions);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
bool ErrorService::validate_json(const std::string &json_str,
|
|
214
|
+
std::string &error_message) {
|
|
215
|
+
std::vector<std::string> suggestions;
|
|
216
|
+
return validate_input("json", json_str, error_message, suggestions);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
std::vector<std::string>
|
|
220
|
+
ErrorService::suggest_recovery_actions(const std::string &error_id) {
|
|
221
|
+
for (const auto &error : error_log) {
|
|
222
|
+
if (error.id == error_id) {
|
|
223
|
+
return error.suggestions;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return {};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
bool ErrorService::attempt_auto_recovery(const std::string &error_id) {
|
|
230
|
+
// Basic auto-recovery logic
|
|
231
|
+
for (const auto &error : error_log) {
|
|
232
|
+
if (error.id == error_id) {
|
|
233
|
+
switch (error.category) {
|
|
234
|
+
case ErrorCategory::FILE_SYSTEM:
|
|
235
|
+
// Try to create missing directories
|
|
236
|
+
return true;
|
|
237
|
+
case ErrorCategory::NETWORK:
|
|
238
|
+
// Retry network operations
|
|
239
|
+
return false; // Not implemented
|
|
240
|
+
default:
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
void ErrorService::register_recovery_handler(
|
|
249
|
+
[[maybe_unused]] ErrorCategory category,
|
|
250
|
+
[[maybe_unused]] std::function<bool(const ErrorInfo &)> handler) {
|
|
251
|
+
// Recovery handler registration - placeholder for future implementation
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
std::string ErrorService::format_error(const ErrorInfo &error,
|
|
255
|
+
bool include_suggestions) {
|
|
256
|
+
std::stringstream ss;
|
|
257
|
+
|
|
258
|
+
auto time_t = std::chrono::system_clock::to_time_t(error.timestamp);
|
|
259
|
+
ss << "[" << std::put_time(std::localtime(&time_t), "%Y-%m-%d %H:%M:%S")
|
|
260
|
+
<< "] ";
|
|
261
|
+
ss << "[" << error_level_to_string(error.level) << "] ";
|
|
262
|
+
ss << "[" << error_category_to_string(error.category) << "] ";
|
|
263
|
+
ss << error.message;
|
|
264
|
+
|
|
265
|
+
if (!error.context.empty()) {
|
|
266
|
+
ss << " (Context: " << error.context << ")";
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (include_suggestions && !error.suggestions.empty()) {
|
|
270
|
+
ss << "\nSuggestions:";
|
|
271
|
+
for (const auto &suggestion : error.suggestions) {
|
|
272
|
+
ss << "\n - " << suggestion;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return ss.str();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
std::string ErrorService::format_error_summary() {
|
|
280
|
+
std::map<ErrorLevel, int> level_counts;
|
|
281
|
+
std::map<ErrorCategory, int> category_counts;
|
|
282
|
+
|
|
283
|
+
for (const auto &error : error_log) {
|
|
284
|
+
level_counts[error.level]++;
|
|
285
|
+
category_counts[error.category]++;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
std::stringstream ss;
|
|
289
|
+
ss << "Error Summary (Total: " << error_log.size() << " errors)\n";
|
|
290
|
+
|
|
291
|
+
ss << "By Level:\n";
|
|
292
|
+
for (const auto &[level, count] : level_counts) {
|
|
293
|
+
ss << " " << error_level_to_string(level) << ": " << count << "\n";
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
ss << "By Category:\n";
|
|
297
|
+
for (const auto &[category, count] : category_counts) {
|
|
298
|
+
ss << " " << error_category_to_string(category) << ": " << count << "\n";
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return ss.str();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
void ErrorService::print_error_report() {
|
|
305
|
+
std::cout << format_error_summary() << std::endl;
|
|
306
|
+
|
|
307
|
+
auto recent = get_recent_errors(5);
|
|
308
|
+
if (!recent.empty()) {
|
|
309
|
+
std::cout << "\nRecent Errors:" << std::endl;
|
|
310
|
+
for (const auto &error : recent) {
|
|
311
|
+
std::cout << format_error(error, true) << std::endl << std::endl;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
bool ErrorService::export_error_log(const std::string &export_path) {
|
|
317
|
+
try {
|
|
318
|
+
nlohmann::json log_json = nlohmann::json::array();
|
|
319
|
+
|
|
320
|
+
for (const auto &error : error_log) {
|
|
321
|
+
nlohmann::json error_json;
|
|
322
|
+
error_json["id"] = error.id;
|
|
323
|
+
error_json["level"] = error_level_to_string(error.level);
|
|
324
|
+
error_json["category"] = error_category_to_string(error.category);
|
|
325
|
+
error_json["message"] = error.message;
|
|
326
|
+
error_json["context"] = error.context;
|
|
327
|
+
error_json["suggestions"] = error.suggestions;
|
|
328
|
+
|
|
329
|
+
auto time_t = std::chrono::system_clock::to_time_t(error.timestamp);
|
|
330
|
+
std::stringstream time_ss;
|
|
331
|
+
time_ss << std::put_time(std::localtime(&time_t), "%Y-%m-%d %H:%M:%S");
|
|
332
|
+
error_json["timestamp"] = time_ss.str();
|
|
333
|
+
|
|
334
|
+
log_json.push_back(error_json);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
std::ofstream file(export_path);
|
|
338
|
+
file << log_json.dump(2);
|
|
339
|
+
|
|
340
|
+
return true;
|
|
341
|
+
|
|
342
|
+
} catch (const std::exception &e) {
|
|
343
|
+
std::cerr << "Failed to export error log: " << e.what() << std::endl;
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
std::string ErrorService::error_level_to_string(ErrorLevel level) {
|
|
349
|
+
switch (level) {
|
|
350
|
+
case ErrorLevel::DEBUG:
|
|
351
|
+
return "DEBUG";
|
|
352
|
+
case ErrorLevel::INFO:
|
|
353
|
+
return "INFO";
|
|
354
|
+
case ErrorLevel::WARNING:
|
|
355
|
+
return "WARNING";
|
|
356
|
+
case ErrorLevel::ERROR:
|
|
357
|
+
return "ERROR";
|
|
358
|
+
case ErrorLevel::CRITICAL:
|
|
359
|
+
return "CRITICAL";
|
|
360
|
+
default:
|
|
361
|
+
return "UNKNOWN";
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
std::string ErrorService::error_category_to_string(ErrorCategory category) {
|
|
366
|
+
switch (category) {
|
|
367
|
+
case ErrorCategory::VALIDATION:
|
|
368
|
+
return "VALIDATION";
|
|
369
|
+
case ErrorCategory::NETWORK:
|
|
370
|
+
return "NETWORK";
|
|
371
|
+
case ErrorCategory::FILE_SYSTEM:
|
|
372
|
+
return "FILE_SYSTEM";
|
|
373
|
+
case ErrorCategory::AUTHENTICATION:
|
|
374
|
+
return "AUTHENTICATION";
|
|
375
|
+
case ErrorCategory::COMMAND_EXECUTION:
|
|
376
|
+
return "COMMAND_EXECUTION";
|
|
377
|
+
case ErrorCategory::MEMORY_MANAGEMENT:
|
|
378
|
+
return "MEMORY_MANAGEMENT";
|
|
379
|
+
case ErrorCategory::CONFIGURATION:
|
|
380
|
+
return "CONFIGURATION";
|
|
381
|
+
case ErrorCategory::UNKNOWN:
|
|
382
|
+
return "UNKNOWN";
|
|
383
|
+
default:
|
|
384
|
+
return "UNKNOWN";
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
ErrorLevel ErrorService::string_to_error_level(const std::string &level_str) {
|
|
389
|
+
if (level_str == "DEBUG")
|
|
390
|
+
return ErrorLevel::DEBUG;
|
|
391
|
+
if (level_str == "INFO")
|
|
392
|
+
return ErrorLevel::INFO;
|
|
393
|
+
if (level_str == "WARNING")
|
|
394
|
+
return ErrorLevel::WARNING;
|
|
395
|
+
if (level_str == "ERROR")
|
|
396
|
+
return ErrorLevel::ERROR;
|
|
397
|
+
if (level_str == "CRITICAL")
|
|
398
|
+
return ErrorLevel::CRITICAL;
|
|
399
|
+
return ErrorLevel::ERROR;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
ErrorCategory
|
|
403
|
+
ErrorService::string_to_error_category(const std::string &category_str) {
|
|
404
|
+
if (category_str == "VALIDATION")
|
|
405
|
+
return ErrorCategory::VALIDATION;
|
|
406
|
+
if (category_str == "NETWORK")
|
|
407
|
+
return ErrorCategory::NETWORK;
|
|
408
|
+
if (category_str == "FILE_SYSTEM")
|
|
409
|
+
return ErrorCategory::FILE_SYSTEM;
|
|
410
|
+
if (category_str == "AUTHENTICATION")
|
|
411
|
+
return ErrorCategory::AUTHENTICATION;
|
|
412
|
+
if (category_str == "COMMAND_EXECUTION")
|
|
413
|
+
return ErrorCategory::COMMAND_EXECUTION;
|
|
414
|
+
if (category_str == "MEMORY_MANAGEMENT")
|
|
415
|
+
return ErrorCategory::MEMORY_MANAGEMENT;
|
|
416
|
+
if (category_str == "CONFIGURATION")
|
|
417
|
+
return ErrorCategory::CONFIGURATION;
|
|
418
|
+
return ErrorCategory::UNKNOWN;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
void ErrorService::set_max_log_entries([[maybe_unused]] size_t max_entries) {
|
|
422
|
+
// Implementation for setting max log entries
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
void ErrorService::set_log_level([[maybe_unused]] ErrorLevel min_level) {
|
|
426
|
+
// Implementation for setting minimum log level
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
bool ErrorService::save_error_config() {
|
|
430
|
+
// Save error configuration - placeholder
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
bool ErrorService::load_error_config() {
|
|
435
|
+
// Load error configuration - placeholder
|
|
436
|
+
return true;
|
|
437
|
+
}
|
|
438
|
+
} // namespace Services
|