![]() |
SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
|
Centralized Exception and Error Handling Utility. More...
#include <error_handler.hpp>
Public Member Functions | |
| error_handler (error_handler const &)=delete | |
| void | operator= (error_handler const &)=delete |
| void | assert_error (const lib::exception &e) |
| Logs error details and throws an exception with ETL_ASSERT(). | |
| void | assert_error (bool condition, const lib::exception &e) |
| Logs error details and throws an exception with ETL_ASSERT() based on the condition. | |
| uint32_t | hwinfo_reset_cause () const |
| Retrieves the hardware reset cause from the MCU. | |
| void | handle (const lib::exception &e) |
| Handles a lib::exception based on its severity. | |
| void | handle (const std::exception &e) |
| Handles a generic exception. | |
| void | handle (const etl::exception &e) |
| Handles an an etl::exception. | |
| template<typename T> | |
| void | assert_error (const char *file, int line) |
| Asserts an error with file and line number information. | |
| template<typename T> | |
| void | assert_error (bool condition, const char *file, int line) |
| Asserts an error based on a condition, with file and line information. | |
| void | system_reboot () const |
| Instructs a system reboot. | |
Static Public Member Functions | |
| static error_handler & | get_instance () |
| Singleton access to the error_handler subsystem. | |
Protected Member Functions | |
| error_handler () | |
| Constructs an error_handler instance. | |
| template<typename T> | |
| void | log (const T &e) const |
Centralized Exception and Error Handling Utility.
The error_handler class serves as the core mechanism for managing exceptions, logging error details, and executing appropriate system-level actions, such as initiating reboots, based on the severity of encountered issues.
This class is designed to handle a range of error scenarios, enabling the system to respond gracefully to both minor operational disruptions and critical failures.
Key features include:
Definition at line 52 of file error_handler.hpp.
|
delete |
|
protected |
Constructs an error_handler instance.
The constructor invokes the private method get_reset_cause() to read and store the hardware reset cause from the MCU. This ensures the reset cause is captured and cleared upon system initialization.
Definition at line 173 of file error_handler.cpp.
|
inline |
Asserts an error based on a condition, with file and line information.
This templated method creates an error object of type T using the provided file and line information, then triggers an assertion only if the condition is false.
| T | The type of exception. |
| condition | The condition to evaluate. |
| file | The source file where the error occurred. |
| line | The line number where the error occurred. |
Definition at line 122 of file error_handler.hpp.
| void satnogs::comms::error_handler::assert_error | ( | bool | condition, |
| const lib::exception & | e ) |
Logs error details and throws an exception with ETL_ASSERT() based on the condition.
Triggers if the condition is false.
| condition | The condition to evaluate. |
| e | The exception object containing error info. |
Definition at line 30 of file error_handler.cpp.
|
inline |
Asserts an error with file and line number information.
This templated method creates an error object of type T using the provided file and line information, then triggers an assertion.
| T | The type of exception to instantiate. |
| file | The source file where the error occurred. |
| line | The line number where the error occurred. |
Definition at line 101 of file error_handler.hpp.
| void satnogs::comms::error_handler::assert_error | ( | const lib::exception & | e | ) |
Logs error details and throws an exception with ETL_ASSERT().
| e | The exception object containing error info. |
Definition at line 15 of file error_handler.cpp.
|
inlinestatic |
Singleton access to the error_handler subsystem.
Definition at line 61 of file error_handler.hpp.
| void satnogs::comms::error_handler::handle | ( | const etl::exception & | e | ) |
Handles an an etl::exception.
Based on the fact that all ETL containers may not cause a catastrophic error on failed operations on them, this handler justs logs the exception occurred.
| e | The exception to handle. |
Definition at line 140 of file error_handler.cpp.
| void satnogs::comms::error_handler::handle | ( | const lib::exception & | e | ) |
Handles a lib::exception based on its severity.
This method logs the given exception and responds to it according to its severity level:
| e | The exception to handle. |
Definition at line 108 of file error_handler.cpp.
| void satnogs::comms::error_handler::handle | ( | const std::exception & | e | ) |
Handles a generic exception.
| e | the exception to handle |
Definition at line 155 of file error_handler.cpp.
| uint32_t satnogs::comms::error_handler::hwinfo_reset_cause | ( | ) | const |
Retrieves the hardware reset cause from the MCU.
Definition at line 41 of file error_handler.cpp.
|
inlineprotected |
Definition at line 136 of file error_handler.hpp.
|
delete |
| void satnogs::comms::error_handler::system_reboot | ( | ) | const |
Instructs a system reboot.
This method instructs the system to reboot. It first sleeps for a short period to allow any buffered logs to be flushed, then requests a cold software reboot. If the reboot fails, a watchdog is expected to take over.
Definition at line 79 of file error_handler.cpp.