GEOS
Public Types | Public Member Functions | Static Public Member Functions | List of all members
geos::ExternalErrorHandler Class Reference

Class to handle external error capture. This class role is to capture and process external error messages, using the geos logger for better tracing, logging and handling of messages. More...

#include <ExternalErrorHandler.hpp>

Public Types

using ErrorHandlingFunctor = OutputStreamDeviation::LineHandlingFunctor
 A functor executed for each error mesage to process, taking the message as the 1st string_view parameter, and the detectionLocation as the 2nd. More...
 

Public Member Functions

 ~ExternalErrorHandler ()
 Destructor, disable all error piping features.
 
void setErrorHandling (ErrorHandlingFunctor &&errorHandlingFunctor)
 Set the function that process the external errors that have been captured. The processing typically consists in using the given error message, adding metadata, and logging the message. More...
 
void enableStderrPipeDeviation (bool enable)
 Enable capture of errors piped from the std::cerr stream. Helpful to capture GLIBC errors, or other errors from dependencies not managed by GEOS itself. More...
 
void flush (std::string_view detectionLocation)
 Process all awaiting captured errors that were produced externally, then clear the error stream. More...
 

Static Public Member Functions

static ExternalErrorHandlerinstance ()
 Strinct singleton pattern has been choosen since we will only have single sources of external errors (stderr for now, we could extend that for HYPRE errors, or for more dependencies). More...
 
static void defaultErrorHandling (std::string_view errorMsg, std::string_view detectionLocation)
 Not designed for direct calls, error handling function in default use if never calling setErrorHandling(). More...
 

Detailed Description

Class to handle external error capture. This class role is to capture and process external error messages, using the geos logger for better tracing, logging and handling of messages.

Definition at line 210 of file ExternalErrorHandler.hpp.

Member Typedef Documentation

◆ ErrorHandlingFunctor

A functor executed for each error mesage to process, taking the message as the 1st string_view parameter, and the detectionLocation as the 2nd.

See also
defaultErrorHandling() for a default implementation.

Definition at line 219 of file ExternalErrorHandler.hpp.

Member Function Documentation

◆ defaultErrorHandling()

static void geos::ExternalErrorHandler::defaultErrorHandling ( std::string_view  errorMsg,
std::string_view  detectionLocation 
)
static

Not designed for direct calls, error handling function in default use if never calling setErrorHandling().

Parameters
errorMsgthe error text message.
detectionLocationA label to describe to the user when the error has been detected.

◆ enableStderrPipeDeviation()

void geos::ExternalErrorHandler::enableStderrPipeDeviation ( bool  enable)

Enable capture of errors piped from the std::cerr stream. Helpful to capture GLIBC errors, or other errors from dependencies not managed by GEOS itself.

Parameters
enableEnable the feature if true, disable it otherwise.
Note
Disabled by default.

◆ flush()

void geos::ExternalErrorHandler::flush ( std::string_view  detectionLocation)

Process all awaiting captured errors that were produced externally, then clear the error stream.

Parameters
detectionLocationA label to describe when the flush() operation is being made, thus explaining to the user when the error has been detected.
See also
setErrorHandling() to set the error processing procedure.

◆ instance()

static ExternalErrorHandler& geos::ExternalErrorHandler::instance ( )
static

Strinct singleton pattern has been choosen since we will only have single sources of external errors (stderr for now, we could extend that for HYPRE errors, or for more dependencies).

Returns
The unique global instance.

◆ setErrorHandling()

void geos::ExternalErrorHandler::setErrorHandling ( ErrorHandlingFunctor &&  errorHandlingFunctor)
inline

Set the function that process the external errors that have been captured. The processing typically consists in using the given error message, adding metadata, and logging the message.

Parameters
errorHandlingFunctorsee ErrorHandlingFunctor.
Note
Implementation treat each independant lines as an single error.

Definition at line 239 of file ExternalErrorHandler.hpp.


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