ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::TaskError Struct Reference

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.

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.

Detailed Description

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 25 of file error_handler.hpp.

Member Function Documentation

◆ rethrow()

void threadschedule::TaskError::rethrow ( ) const
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.

Exceptions
Theoriginal exception stored in exception.

Definition at line 79 of file error_handler.hpp.

References exception.

◆ what()

auto threadschedule::TaskError::what ( ) const -> std::string
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.

Returns
The exception message, "Unknown exception" if the stored exception is not derived from std::exception, or "No exception" if the pointer is empty.

Definition at line 50 of file error_handler.hpp.

References exception.

Member Data Documentation

◆ exception

std::exception_ptr threadschedule::TaskError::exception

The captured exception. Never null when produced by the library.

Definition at line 28 of file error_handler.hpp.

Referenced by rethrow(), threadschedule::HighPerformancePoolWithErrors::submit(), threadschedule::HighPerformancePoolWithErrors::submit_with_description(), and what().

◆ task_description

std::string threadschedule::TaskError::task_description

Optional human-readable label supplied when the task was submitted.

Definition at line 31 of file error_handler.hpp.

Referenced by threadschedule::HighPerformancePoolWithErrors::submit_with_description().

◆ thread_id

std::thread::id threadschedule::TaskError::thread_id

Id of the thread on which the exception was thrown.

Definition at line 34 of file error_handler.hpp.

Referenced by threadschedule::HighPerformancePoolWithErrors::submit(), and threadschedule::HighPerformancePoolWithErrors::submit_with_description().

◆ timestamp

std::chrono::steady_clock::time_point threadschedule::TaskError::timestamp

Monotonic timestamp recorded immediately after the exception was caught.

Definition at line 37 of file error_handler.hpp.

Referenced by threadschedule::HighPerformancePoolWithErrors::submit(), and threadschedule::HighPerformancePoolWithErrors::submit_with_description().


The documentation for this struct was generated from the following file: