-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use std::optional<std::string> with nullopt instead of empty string for reuqest_clear_error function * Move error related files in to subdirectory * Remove error attribute persistent * Add error attribute state (Active/ClearedByModule/ClearedByReboot) * Add error_exceptions.hpp/cpp * Add error_type_map.hpp/cpp * Add error_json.cpp * Rename error_manager -> error_comm_bridge * Add error_manager that is called by error_comm_bridge * Rename error_database -> error_database_map * Add abstract class error_database Signed-off-by: Andreas Heinrich <[email protected]> Minor suggestions in PR: * Update include/utils/error/error_exceptions.hpp * Update lib/error/error_database_map.cpp * Update lib/error/error_type_map.cpp * Update lib/error/error_type_map.cpp * Update lib/everest.cpp Co-authored-by: Kai Hermann <[email protected]> Signed-off-by: Andreas Heinrich <[email protected]>
- Loading branch information
1 parent
a98d614
commit b3a5dad
Showing
32 changed files
with
1,121 additions
and
657 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
#ifndef UTILS_ERROR_HPP | ||
#define UTILS_ERROR_HPP | ||
|
||
#include <string> | ||
|
||
#include <utils/date.hpp> | ||
#include <utils/types.hpp> | ||
|
||
namespace Everest { | ||
namespace error { | ||
|
||
enum class Severity { | ||
Low, | ||
Medium, | ||
High | ||
}; | ||
std::string severity_to_string(const Severity& s); | ||
Severity string_to_severity(const std::string& s); | ||
|
||
struct UUID { | ||
UUID(); | ||
explicit UUID(const std::string& uuid); | ||
bool operator<(const UUID& other) const; | ||
bool operator==(const UUID& other) const; | ||
bool operator!=(const UUID& other) const; | ||
std::string to_string() const; | ||
|
||
std::string uuid; | ||
}; | ||
|
||
using ErrorType = std::string; | ||
|
||
enum class State { | ||
Active, | ||
ClearedByModule, | ||
ClearedByReboot | ||
}; | ||
std::string state_to_string(const State& s); | ||
State string_to_state(const std::string& s); | ||
|
||
/// | ||
/// \brief The Error struct represents an error object | ||
/// | ||
struct Error { | ||
using time_point = date::utc_clock::time_point; | ||
Error(const ErrorType& type, const std::string& message, const std::string& description, | ||
const ImplementationIdentifier& from, const Severity& severity, const time_point& timestamp, const UUID& uuid, | ||
const State& state = State::Active); | ||
Error(const ErrorType& type, const std::string& message, const std::string& description, | ||
const ImplementationIdentifier& from, const Severity& severity = Severity::Low); | ||
Error(const ErrorType& type, const std::string& message, const std::string& description, | ||
const std::string& from_module, const std::string& from_implementation, | ||
const Severity& severity = Severity::Low); | ||
ErrorType type; | ||
std::string description; | ||
std::string message; | ||
Severity severity; | ||
ImplementationIdentifier from; | ||
time_point timestamp; | ||
UUID uuid; | ||
State state; | ||
}; | ||
|
||
using ErrorHandle = UUID; | ||
using ErrorPtr = std::shared_ptr<Error>; | ||
using ErrorCallback = std::function<void(Error)>; | ||
|
||
} // namespace error | ||
} // namespace Everest | ||
|
||
#endif // UTILS_ERROR_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
#ifndef UTILS_ERROR_DATABASE_HPP | ||
#define UTILS_ERROR_DATABASE_HPP | ||
|
||
#include <list> | ||
#include <memory> | ||
|
||
#include <utils/error/error_filter.hpp> | ||
|
||
namespace Everest { | ||
namespace error { | ||
|
||
class ErrorDatabase { | ||
public: | ||
using EditErrorFunc = std::function<void(ErrorPtr)>; | ||
|
||
ErrorDatabase() = default; | ||
|
||
virtual void add_error(ErrorPtr error) = 0; | ||
virtual std::list<ErrorPtr> get_errors(const std::list<ErrorFilter>& filters) const = 0; | ||
virtual std::list<ErrorPtr> edit_errors(const std::list<ErrorFilter>& filters, EditErrorFunc edit_func) = 0; | ||
virtual std::list<ErrorPtr> remove_errors(const std::list<ErrorFilter>& filters) = 0; | ||
}; | ||
|
||
} // namespace error | ||
} // namespace Everest | ||
|
||
#endif // UTILS_ERROR_DATABASE_HPP |
Oops, something went wrong.