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

Class to format and write different error/warning information that occured during the initialization. More...

#include <ErrorHandling.hpp>

Classes

struct  ErrorContext
 
struct  ErrorMsg
 Struct to construct the error/warning object. More...
 

Public Types

enum class  MsgType { Error , Warning , Exception , Undefined }
 

Public Member Functions

bool isOutputFileEnabled () const
 
void enableFileOutput (bool value)
 Enable the YAML file output, which is false by default. More...
 
void setOutputFilename (std::string_view filename)
 Set the name of the YAML file if specified by user default is "errors.yaml". More...
 
std::string_view getOutputFilename ()
 
ErrorMsgcurrentErrorMsg ()
 Gives acces to the error message that is currently being constructed, potencially at various application layers Use flushErrorMsg() when the message is fully constructed and you want it to be output. More...
 
void createFile ()
 Create the YAML file or overwrite the contents if a YAML file of the same name already exists And write its header when the command line option is enabled.
 
void flushErrorMsg (ErrorMsg &errorMsg)
 Write all the information retrieved about the error/warning message into the YAML file and reset the errorMsg instance to its initial state. More...
 

Static Public Member Functions

static GEOS_HOST ErrorLoggerglobal ()
 
static std::string toString (MsgType type)
 Convert a MsgType into a string. More...
 

Detailed Description

Class to format and write different error/warning information that occured during the initialization.

Definition at line 32 of file ErrorHandling.hpp.

Member Enumeration Documentation

◆ MsgType

Enum listing the different types of possible errors

Definition at line 40 of file ErrorHandling.hpp.

Member Function Documentation

◆ currentErrorMsg()

ErrorMsg& geos::ErrorLogger::currentErrorMsg ( )
inline

Gives acces to the error message that is currently being constructed, potencially at various application layers Use flushErrorMsg() when the message is fully constructed and you want it to be output.

Returns
Reference to the current instance for method chaining.

Definition at line 263 of file ErrorHandling.hpp.

◆ enableFileOutput()

void geos::ErrorLogger::enableFileOutput ( bool  value)
inline

Enable the YAML file output, which is false by default.

Parameters
valueA value of true enable the file writing

Definition at line 240 of file ErrorHandling.hpp.

◆ flushErrorMsg()

void geos::ErrorLogger::flushErrorMsg ( ErrorMsg errorMsg)

Write all the information retrieved about the error/warning message into the YAML file and reset the errorMsg instance to its initial state.

Parameters
errorMsga constant reference to the error

◆ getOutputFilename()

std::string_view geos::ErrorLogger::getOutputFilename ( )
inline
Returns
The file name of the output error file

Definition at line 254 of file ErrorHandling.hpp.

◆ global()

static GEOS_HOST ErrorLogger& geos::ErrorLogger::global ( )
static
Returns
Global instance of the ErrorLogger class used for error/warning reporting.

This global instance is used across the codebase to log errors, warnings, and exceptions, and to write structured output of errors. It is used through the logging macros.

Note
- local instances are possible for more specialized logging.
  • currently not available on GPU, use GEOS_WARNING/ERROR/ASSERT macros for this usecase.

◆ isOutputFileEnabled()

bool geos::ErrorLogger::isOutputFileEnabled ( ) const
inline
Returns
true if the YAML file output is enabled

Definition at line 233 of file ErrorHandling.hpp.

◆ setOutputFilename()

void geos::ErrorLogger::setOutputFilename ( std::string_view  filename)
inline

Set the name of the YAML file if specified by user default is "errors.yaml".

Parameters
filenamethe name of the YAML file

Definition at line 248 of file ErrorHandling.hpp.

◆ toString()

static std::string geos::ErrorLogger::toString ( MsgType  type)
static

Convert a MsgType into a string.

Parameters
typethe message type label
Returns
the string representation of the message type

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