Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the error manager: allow same error and sub-error if created by d… #203

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions lib/error/error_manager_req_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,17 @@ void ErrorManagerReqGlobal::on_error_raised(const Error& error) {
EVLOG_error << "Error type '" << error.type << "' is not defined, ignoring error";
return;
}
std::list<ErrorPtr> errors = database->get_errors({
ErrorFilter(TypeFilter(error.type)),
ErrorFilter(SubTypeFilter(error.sub_type)),
});
std::list<ErrorPtr> errors =
database->get_errors({ErrorFilter(TypeFilter(error.type)), ErrorFilter(SubTypeFilter(error.sub_type)),
ErrorFilter(OriginFilter(error.origin))});
if (!errors.empty()) {
EVLOG_error << "Error of type '" << error.type << "' and sub type '" << error.sub_type
<< "' is already raised, ignoring new error";
return;
}
database->add_error(std::make_shared<Error>(error));
errors = database->get_errors({
ErrorFilter(TypeFilter(error.type)),
ErrorFilter(SubTypeFilter(error.sub_type)),
});
errors = database->get_errors({ErrorFilter(TypeFilter(error.type)), ErrorFilter(SubTypeFilter(error.sub_type)),
ErrorFilter(OriginFilter(error.origin))});
if (errors.size() != 1) {
EVLOG_error << "Error wasn't added, type: " << error.type << ", sub type: " << error.sub_type;
return;
Expand All @@ -65,19 +62,17 @@ void ErrorManagerReqGlobal::on_error_cleared(const Error& error) {
EVLOG_error << "Error type '" << error.type << "' is not defined, ignoring error";
return;
}
std::list<ErrorPtr> errors = database->get_errors({
ErrorFilter(TypeFilter(error.type)),
ErrorFilter(SubTypeFilter(error.sub_type)),
});
std::list<ErrorPtr> errors =
database->get_errors({ErrorFilter(TypeFilter(error.type)), ErrorFilter(SubTypeFilter(error.sub_type)),
ErrorFilter(OriginFilter(error.origin))});
if (errors.empty()) {
EVLOG_error << "Error of type '" << error.type << "' and sub type '" << error.sub_type
<< "' is not raised, ignoring clear error";
return;
}
std::list<ErrorPtr> res = database->remove_errors({
ErrorFilter(TypeFilter(error.type)),
ErrorFilter(SubTypeFilter(error.sub_type)),
});
std::list<ErrorPtr> res =
database->remove_errors({ErrorFilter(TypeFilter(error.type)), ErrorFilter(SubTypeFilter(error.sub_type)),
ErrorFilter(OriginFilter(error.origin))});
if (res.size() > 1) {
EVLOG_error << "More than one error is cleared, type: " << error.type << ", sub type: " << error.sub_type;
return;
Expand Down
Loading