MayaFlux 0.1.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 308 of file Archivist.hpp.

311{
312 auto ep = std::current_exception();
313 if (!ep) {
314 Archivist::instance().scribe(Severity::ERROR, component, context,
315 "error_rethrow called outside of a catch", location);
316 std::terminate();
317 }
318
319 try {
320 std::rethrow_exception(ep);
321 } catch (const std::exception& e) {
322 std::string msg = std::string(e.what());
323 if (!additional_context.empty()) {
324 msg = std::string(additional_context) + ": " + msg;
325 }
326 Archivist::instance().scribe(Severity::ERROR, component, context, msg, location);
327 std::rethrow_exception(ep);
328 } catch (...) {
329 std::string msg = "Unknown exception";
330 if (!additional_context.empty()) {
331 msg = std::string(additional_context) + ": " + msg;
332 }
333 Archivist::instance().scribe(Severity::ERROR, component, context, msg, location);
334 std::rethrow_exception(ep);
335 }
336}

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: