dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
ErrorManager Struct Referencefinal

Receives the errors that have no caller: the exceptions of the callbacks of the dxFeed Graal SDK and of the code the library runs on its own. More...

#include <ErrorManager.hpp>

Public Types

using Handler = std::function<void(const ErrorInfo &)>
 The handler of the errors. A null handler turns the output off.

Static Public Member Functions

static void report (StringParam component, StringParam message, const std::source_location &location=std::source_location::current()) noexcept
 Reports an error: adds it to the journal and passes it to the handler.
static void reportException (StringParam component, const std::exception_ptr &exception, const std::source_location &location=std::source_location::current()) noexcept
 Reports an exception: adds it to the journal and passes it to the handler.
static void reportWarning (StringParam component, StringParam message, const std::source_location &location=std::source_location::current()) noexcept
 Reports a warning: adds it to the journal and passes it to the handler like an error, with the level ErrorInfo::Level::WARN.
static void setHandler (Handler handler)
 Sets the handler of the errors.
static void resetHandler () noexcept
 Restores the default handler, which writes one line per error to stderr.
static void defaultHandler (const ErrorInfo &error) noexcept
 The default handler: writes ErrorInfo::toString() of the error as one line to stderr.
static void setCapacity (std::size_t capacity)
 Sets the number of the last errors that the journal keeps.
static std::size_t getCapacity () noexcept
static std::vector< ErrorInfo > getErrors ()
static std::optional< ErrorInfo > getLastError ()
static void clearErrors () noexcept
 Removes all the errors from the journal. The numbers of the next errors continue.

Static Public Attributes

static constexpr std::size_t DEFAULT_CAPACITY = 128
 The default capacity of the journal.

Detailed Description

Receives the errors that have no caller: the exceptions of the callbacks of the dxFeed Graal SDK and of the code the library runs on its own.

See Error handling.

Member Function Documentation

◆ defaultHandler()

void ErrorManager::defaultHandler ( const ErrorInfo & error)
staticnoexcept

The default handler: writes ErrorInfo::toString() of the error as one line to stderr.

Parameters
errorThe error.

◆ getCapacity()

std::size_t ErrorManager::getCapacity ( )
staticnoexcept
Returns
The number of the last errors that the journal keeps.

◆ getErrors()

std::vector< ErrorInfo > ErrorManager::getErrors ( )
static
Returns
The copies of the errors in the journal, from the oldest to the newest.

◆ getLastError()

std::optional< ErrorInfo > ErrorManager::getLastError ( )
static
Returns
The copy of the newest error in the journal, or an empty optional when the journal is empty.

◆ report()

void ErrorManager::report ( StringParam component,
StringParam message,
const std::source_location & location = std::source_location::current() )
staticnoexcept

Reports an error: adds it to the journal and passes it to the handler.

Parameters
componentThe part of the code that reports the error.
messageThe message of the error.
locationThe source location of the report.

◆ reportException()

void ErrorManager::reportException ( StringParam component,
const std::exception_ptr & exception,
const std::source_location & location = std::source_location::current() )
staticnoexcept

Reports an exception: adds it to the journal and passes it to the handler.

A JavaException gives the Java class and stack trace, another std::exception its what(), any other exception the message unknown exception.

Parameters
componentThe part of the code that reports the error.
exceptionThe exception, usually std::current_exception() in a catch block.
locationThe source location of the report.

◆ reportWarning()

void ErrorManager::reportWarning ( StringParam component,
StringParam message,
const std::source_location & location = std::source_location::current() )
staticnoexcept

Reports a warning: adds it to the journal and passes it to the handler like an error, with the level ErrorInfo::Level::WARN.

The ids come from the same counter as the ids of the errors.

Parameters
componentThe part of the code that reports the warning.
messageThe message of the warning.
locationThe source location of the report.

◆ setCapacity()

void ErrorManager::setCapacity ( std::size_t capacity)
static

Sets the number of the last errors that the journal keeps.

Older errors are dropped at once if there are more.

Parameters
capacityThe capacity; 0 turns the journal off.

◆ setHandler()

void ErrorManager::setHandler ( Handler handler)
static

Sets the handler of the errors.

Parameters
handlerThe new handler, or a null handler to turn the output off (the journal keeps the errors).