RTC Toolkit  2.0.0
Public Member Functions | Friends | List of all members
rtctk::componentFramework::NestedExceptionPrinter Class Reference

Adapter object intended to be used in contexts without direct access to the output-stream object. More...

#include <exceptions.hpp>

Public Member Functions

 NestedExceptionPrinter (std::exception const &exception) noexcept
 Construct from exception derived from std::exception. More...
 
 NestedExceptionPrinter (std::exception_ptr ptr) noexcept
 Construct from exception_ptr. More...
 
std::string Str () const
 Convenience function for constructing a std::string from the exception. More...
 

Friends

std::ostream & operator<< (std::ostream &os, NestedExceptionPrinter const &printer)
 Formats exception from printer using PrintNestedExceptions. More...
 

Detailed Description

Adapter object intended to be used in contexts without direct access to the output-stream object.

try {
  MaybeThrows();
} catch (std::exception const& e) {
  LOG4CPLUS_ERROR(logger, "MaybeThrow failed with:\n" << NestedExceptionPrinter(e));
}

Constructor & Destructor Documentation

◆ NestedExceptionPrinter() [1/2]

rtctk::componentFramework::NestedExceptionPrinter::NestedExceptionPrinter ( std::exception const &  exception)
inlineexplicitnoexcept

Construct from exception derived from std::exception.

◆ NestedExceptionPrinter() [2/2]

rtctk::componentFramework::NestedExceptionPrinter::NestedExceptionPrinter ( std::exception_ptr  ptr)
inlineexplicitnoexcept

Construct from exception_ptr.

Member Function Documentation

◆ Str()

std::string rtctk::componentFramework::NestedExceptionPrinter::Str ( ) const
inline

Convenience function for constructing a std::string from the exception.

Returns
Formatted string

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
NestedExceptionPrinter const &  printer 
)
friend

Formats exception from printer using PrintNestedExceptions.

Parameters
osoutput stream to output to.
printerPrinter adapter to format.
Returns
os

The documentation for this class was generated from the following file: