20#ifndef ORES_QT_EXCEPTION_HELPER_HPP
21#define ORES_QT_EXCEPTION_HELPER_HPP
26#include <boost/exception/diagnostic_information.hpp>
27#include "ores.logging/boost_severity.hpp"
52 template<
typename Logger,
typename EmitFunc>
54 const std::exception& e,
55 const QString& entity_name,
57 EmitFunc emit_error) {
59 const auto details = QString::fromStdString(
60 boost::diagnostic_information(e));
62 BOOST_LOG_SEV(logger, ores::logging::error)
63 <<
"Exception fetching " << entity_name.toStdString() <<
": "
64 << details.toStdString();
66 const auto message = QString(
"Failed to fetch %1 from server.")
69 emit_error(message, details);
88 template<
typename ResultType,
typename FetchFunc>
90 FetchFunc&& fetch_func,
91 const QString& entity_name) {
95 }
catch (
const std::exception& e) {
97 result.success =
false;
98 result.error_message = QString(
"Failed to fetch %1 from server.")
100 result.error_details = QString::fromStdString(
101 boost::diagnostic_information(e));
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Helper class for handling exceptions and server errors in async operations.
Definition ExceptionHelper.hpp:36
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.
Definition ExceptionHelper.hpp:89
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.
Definition ExceptionHelper.hpp:53