MayaFlux 1.0.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 389 of file Archivist.hpp.

392{
393 auto ep = std::current_exception();
394 if (!ep) {
395 Archivist::instance().scribe(Severity::ERROR, component, context,
396 "error_rethrow called outside of a catch", location);
397 Archivist::instance().flush();
398 std::terminate();
399 }
400
401 try {
402 std::rethrow_exception(ep);
403 } catch (const std::exception& e) {
404 std::string msg = std::string(e.what());
405 if (!additional_context.empty()) {
406 msg = std::string(additional_context) + ": " + msg;
407 }
408 Archivist::instance().scribe(Severity::ERROR, component, context, msg, location);
409 Archivist::instance().flush();
410 std::rethrow_exception(ep);
411 } catch (...) {
412 std::string msg = "Unknown exception";
413 if (!additional_context.empty()) {
414 msg = std::string(additional_context) + ": " + msg;
415 }
416 Archivist::instance().scribe(Severity::ERROR, component, context, msg, location);
417 Archivist::instance().flush();
418 std::rethrow_exception(ep);
419 }
420}

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

Referenced by error_rethrow(), and MayaFlux::IO::IOManager::IOManager().

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