Helper class for handling exceptions and server errors in async operations.
More...
#include <ExceptionHelper.hpp>
|
| template<typename Logger , typename EmitFunc > |
| static void | handle_fetch_exception (const std::exception &e, const QString &entity_name, Logger &logger, EmitFunc emit_error) |
| | Handles a fetch exception by logging and emitting an error signal.
|
| |
| template<typename ResultType , typename FetchFunc > |
| static ResultType | wrap_async_fetch (FetchFunc &&fetch_func, const QString &entity_name) |
| | Wraps an async fetch operation to capture exceptions before Qt can wrap them.
|
| |
Helper class for handling exceptions and server errors in async operations.
Provides standardized handling for exceptions thrown from QFuture operations.
◆ handle_fetch_exception()
template<typename Logger , typename EmitFunc >
| static void handle_fetch_exception |
( |
const std::exception & |
e, |
|
|
const QString & |
entity_name, |
|
|
Logger & |
logger, |
|
|
EmitFunc |
emit_error |
|
) |
| |
|
static |
Handles a fetch exception by logging and emitting an error signal.
Extracts detailed diagnostic information from the exception using boost::diagnostic_information, logs the error, and calls the emit callback with a user-friendly message and technical details.
- Template Parameters
-
| Logger | The logger type (must support BOOST_LOG_SEV). |
| EmitFunc | Callable that takes (const QString& message, const QString& details). |
- Parameters
-
| e | The exception that was caught. |
| entity_name | The name of the entity being fetched (e.g., "origin dimensions"). |
| logger | Reference to the logger instance. |
| emit_error | Callback to emit the error signal. |
◆ wrap_async_fetch()
template<typename ResultType , typename FetchFunc >
| static ResultType wrap_async_fetch |
( |
FetchFunc && |
fetch_func, |
|
|
const QString & |
entity_name |
|
) |
| |
|
static |
Wraps an async fetch operation to capture exceptions before Qt can wrap them.
This function catches exceptions inside the async task (before Qt's exception handling), capturing full diagnostic information. The result type must have the following fields:
- bool success
- QString error_message
- QString error_details
- Template Parameters
-
| ResultType | The FetchResult type (must have success, error_message, error_details). |
| FetchFunc | Callable that returns ResultType. |
- Parameters
-
| fetch_func | The function that performs the actual fetch. |
| entity_name | The name of the entity being fetched (for error messages). |
- Returns
- ResultType with success=false and error fields populated on exception.