|
ThreadSchedule 2.0.0
Modern C++ thread management library
|
Holds diagnostic information captured from a failed task. More...
#include <error_handler.hpp>
Public Member Functions | |
| auto | what () const -> std::string |
| Extract the message string from the stored exception. | |
| void | rethrow () const |
| Re-throw the original exception. | |
Static Public Member Functions | |
| static auto | capture (std::string description={}) -> TaskError |
| Capture the current in-flight exception into a TaskError. | |
Public Attributes | |
| std::exception_ptr | exception |
| The captured exception. Never null when produced by the library. | |
| std::string | task_description |
| Optional human-readable label supplied when the task was submitted. | |
| std::thread::id | thread_id |
| Id of the thread on which the exception was thrown. | |
| std::chrono::steady_clock::time_point | timestamp |
| Monotonic timestamp recorded immediately after the exception was caught. | |
Holds diagnostic information captured from a failed task.
TaskError is a value type (copyable and movable) that bundles the original exception together with context about where and when the failure occurred.
Instances are typically created by ErrorHandledTask and forwarded to registered ErrorCallback functions through an ErrorHandler.
Definition at line 32 of file error_handler.hpp.
|
inlinestatic |
Capture the current in-flight exception into a TaskError.
Must be called inside a catch block. Fills exception, thread_id, and timestamp; optionally sets task_description.
Definition at line 52 of file error_handler.hpp.
Referenced by threadschedule::ErrorHandledTask< Func >::operator()().
|
inline |
Re-throw the original exception.
If the stored exception pointer is non-null the exception is re-thrown via std::rethrow_exception. This will terminate the program if called outside a try / catch block.
| The | original exception stored in exception. |
Definition at line 102 of file error_handler.hpp.
References exception.
|
inlinenodiscard |
Extract the message string from the stored exception.
Internally re-throws the exception and catches it as std::exception to call what(). This is safe but incurs the overhead of a throw / catch round-trip; avoid calling in tight loops.
"Unknown exception" if the stored exception is not derived from std::exception, or "No exception" if the pointer is empty. Definition at line 73 of file error_handler.hpp.
References exception.
| std::exception_ptr threadschedule::TaskError::exception |
The captured exception. Never null when produced by the library.
Definition at line 35 of file error_handler.hpp.
| std::string threadschedule::TaskError::task_description |
Optional human-readable label supplied when the task was submitted.
Definition at line 38 of file error_handler.hpp.
| std::thread::id threadschedule::TaskError::thread_id |
Id of the thread on which the exception was thrown.
Definition at line 41 of file error_handler.hpp.
| std::chrono::steady_clock::time_point threadschedule::TaskError::timestamp |
Monotonic timestamp recorded immediately after the exception was caught.
Definition at line 44 of file error_handler.hpp.