MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ error_rethrow() [2/2]

void MayaFlux::Journal::error_rethrow ( Component  component,
Context  context,
std::source_location  location = std::source_location::current(),
std::string_view  additional_context = "" 
)
inline

Catch and log an exception, then rethrow it.

This function is intended to be called within a catch block.

Parameters
ComponentThe component generating the log message.
ContextThe execution context of the log message.
locationThe source location (file, line, function) of the log call.
additional_contextOptional additional context to prepend to the exception message.

Definition at line 357 of file Archivist.hpp.

360{
361 auto ep = std::current_exception();
362 if (!ep) {
363 Archivist::instance().scribe(Severity::ERROR, component, context,
364 "error_rethrow called outside of a catch", location);
365 std::terminate();
366 }
367
368 try {
369 std::rethrow_exception(ep);
370 } catch (const std::exception& e) {
371 std::string msg = std::string(e.what());
372 if (!additional_context.empty()) {
373 msg = std::string(additional_context) + ": " + msg;
374 }
375 Archivist::instance().scribe(Severity::ERROR, component, context, msg, location);
376 std::rethrow_exception(ep);
377 } catch (...) {
378 std::string msg = "Unknown exception";
379 if (!additional_context.empty()) {
380 msg = std::string(additional_context) + ": " + msg;
381 }
382 Archivist::instance().scribe(Severity::ERROR, component, context, msg, location);
383 std::rethrow_exception(ep);
384 }
385}

References ERROR, MayaFlux::Journal::Archivist::instance(), and MayaFlux::Journal::Archivist::scribe().

Referenced by error_rethrow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: