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>
|
|
using | Handler = std::function<void(const ErrorInfo &)> |
| | The handler of the errors. A null handler turns the output off.
|
|
| 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 constexpr std::size_t | DEFAULT_CAPACITY = 128 |
| | The default capacity of the journal.
|
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.
◆ defaultHandler()
| void ErrorManager::defaultHandler |
( |
const ErrorInfo & | error | ) |
|
|
staticnoexcept |
◆ 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
-
| component | The part of the code that reports the error. |
| message | The message of the error. |
| location | The 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
-
| component | The part of the code that reports the error. |
| exception | The exception, usually std::current_exception() in a catch block. |
| location | The 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
-
| component | The part of the code that reports the warning. |
| message | The message of the warning. |
| location | The 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
-
| capacity | The capacity; 0 turns the journal off. |
◆ setHandler()
| void ErrorManager::setHandler |
( |
Handler | handler | ) |
|
|
static |
Sets the handler of the errors.
- Parameters
-
| handler | The new handler, or a null handler to turn the output off (the journal keeps the errors). |