Icarus
Vehicle Simulation as a Transformable Computational Graph, built on Vulcan and Janus
Loading...
Searching...
No Matches
icarus::ErrorHandler Class Reference

Central error handler integrating logging and exceptions. More...

#include <ErrorHandler.hpp>

Public Member Functions

 ErrorHandler (LogService &log_service)
void SetPolicy (Severity severity, ErrorPolicy policy)
 Set default policy for each severity level.
void SetCallback (ErrorCallback callback)
 Set callback for error handling (can override default policy).
void SetMaxErrors (std::size_t max_errors)
 Set maximum errors before automatic abort.
ErrorPolicy Report (const SimulationError &error)
ErrorPolicy Report (const Error &exception, double sim_time=0.0, const std::string &component="")
 Report an exception, extracting info automatically.
void ReportFatal (const std::string &message, double sim_time=0.0)
 Report a fatal error and trigger crash.
std::size_t GetErrorCount (Severity severity) const
 Get count of errors at each severity.
std::size_t GetTotalErrorCount () const
 Get total error count (WARNING and above).
bool ShouldAbort () const
 Check if simulation should abort.
std::optional< SimulationErrorGetFatalError () const
 Get the first fatal error (if any).
bool ProcessBufferedErrors ()
void Reset ()
 Clear error counts (for new run).

Detailed Description

Central error handler integrating logging and exceptions.

Bridges the gap between:

Constructor & Destructor Documentation

◆ ErrorHandler()

icarus::ErrorHandler::ErrorHandler ( LogService & log_service)
inlineexplicit

Member Function Documentation

◆ GetErrorCount()

std::size_t icarus::ErrorHandler::GetErrorCount ( Severity severity) const
inlinenodiscard

Get count of errors at each severity.

◆ GetFatalError()

std::optional< SimulationError > icarus::ErrorHandler::GetFatalError ( ) const
inlinenodiscard

Get the first fatal error (if any).

◆ GetTotalErrorCount()

std::size_t icarus::ErrorHandler::GetTotalErrorCount ( ) const
inlinenodiscard

Get total error count (WARNING and above).

◆ ProcessBufferedErrors()

bool icarus::ErrorHandler::ProcessBufferedErrors ( )
inlinenodiscard

Check buffered logs for errors, apply policies. Called by Simulator after Flush().

Returns
true if simulation should abort (fatal error or max errors exceeded)

◆ Report() [1/2]

ErrorPolicy icarus::ErrorHandler::Report ( const Error & exception,
double sim_time = 0.0,
const std::string & component = "" )
inline

Report an exception, extracting info automatically.

◆ Report() [2/2]

ErrorPolicy icarus::ErrorHandler::Report ( const SimulationError & error)
inline

Report an error (from exception or direct call) Returns the policy that should be applied

◆ ReportFatal()

void icarus::ErrorHandler::ReportFatal ( const std::string & message,
double sim_time = 0.0 )
inline

Report a fatal error and trigger crash.

◆ Reset()

void icarus::ErrorHandler::Reset ( )
inline

Clear error counts (for new run).

◆ SetCallback()

void icarus::ErrorHandler::SetCallback ( ErrorCallback callback)
inline

Set callback for error handling (can override default policy).

◆ SetMaxErrors()

void icarus::ErrorHandler::SetMaxErrors ( std::size_t max_errors)
inline

Set maximum errors before automatic abort.

◆ SetPolicy()

void icarus::ErrorHandler::SetPolicy ( Severity severity,
ErrorPolicy policy )
inline

Set default policy for each severity level.

◆ ShouldAbort()

bool icarus::ErrorHandler::ShouldAbort ( ) const
inlinenodiscard

Check if simulation should abort.


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