Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::std_exception_wrapper Class Reference

wrapper for std::exception More...

#include <exception.hpp>

Inheritance diagram for fc::std_exception_wrapper:
Collaboration diagram for fc::std_exception_wrapper:

Public Member Functions

 std_exception_wrapper (log_message &&m, std::exception_ptr e=std::current_exception(), const std::string &name_value="exception", const std::string &what_value="unspecified")
 
std::exception_ptr get_inner_exception () const
 
virtual NO_RETURN void dynamic_rethrow_exception () const
 
virtual std::shared_ptr< exceptiondynamic_copy_exception () const
 
- Public Member Functions inherited from fc::exception
 exception (int64_t code=unspecified_exception_code, const std::string &name_value="exception", const std::string &what_value="unspecified")
 
 exception (log_message &&, int64_t code=unspecified_exception_code, const std::string &name_value="exception", const std::string &what_value="unspecified")
 
 exception (log_messages &&, int64_t code=unspecified_exception_code, const std::string &name_value="exception", const std::string &what_value="unspecified")
 
 exception (const log_messages &, int64_t code=unspecified_exception_code, const std::string &name_value="exception", const std::string &what_value="unspecified")
 
 exception (const exception &e)
 
 exception (exception &&e)
 
virtual ~exception ()
 
const char * name () const throw ()
 
int64_t code () const throw ()
 
const char * what () const noexcept override
 
const log_messagesget_log () const
 
void append_log (log_message m)
 
std::string to_detail_string (log_level ll=log_level::all) const
 
std::string to_string (log_level ll=log_level::info) const
 
std::string top_message () const
 
exceptionoperator= (const exception &copy)
 
exceptionoperator= (exception &&copy)
 

Static Public Member Functions

static std_exception_wrapper from_current_exception (const std::exception &e)
 

Additional Inherited Members

- Public Types inherited from fc::exception
enum  code_enum { code_value = unspecified_exception_code }
 
- Static Public Attributes inherited from fc::exception
static constexpr fc::microseconds format_time_limit = fc::milliseconds( 10 )
 
- Protected Attributes inherited from fc::exception
std::unique_ptr< detail::exception_impl > my
 

Detailed Description

The original exception is captured as a std::exception_ptr which may be rethrown. The std::exception_ptr does not propgate across process boundaries.

Definition at line 179 of file exception.hpp.

Constructor & Destructor Documentation

◆ std_exception_wrapper()

fc::std_exception_wrapper::std_exception_wrapper ( log_message && m,
std::exception_ptr e = std::current_exception(),
const std::string & name_value = "exception",
const std::string & what_value = "unspecified" )
explicit

Definition at line 327 of file exception.cpp.

330 :exception( fc::move(m), exception_code::std_exception_code, name_value, what_value )
331 {
332 _inner = {std::move(e)};
333 }
exception(int64_t code=unspecified_exception_code, const std::string &name_value="exception", const std::string &what_value="unspecified")
Definition exception.cpp:93
@ std_exception_code
Definition exception.hpp:32

Member Function Documentation

◆ dynamic_copy_exception()

std::shared_ptr< exception > fc::std_exception_wrapper::dynamic_copy_exception ( ) const
virtual

This is equivalent to:

try { throwAsDynamic_exception(); }
catch( ... ) { return std::current_exception(); }

Reimplemented from fc::exception.

Definition at line 351 of file exception.cpp.

352 {
353 auto e = std::make_shared<std_exception_wrapper>( *this );
354 e->_inner = _inner;
355 return e;
356 }

◆ dynamic_rethrow_exception()

NO_RETURN void fc::std_exception_wrapper::dynamic_rethrow_exception ( ) const
virtual

Throw this exception as its most derived type.

Note
does not return.

Rethrows the exception restoring the proper type based upon the error code. This is used to propagate exception types across conversions to/from JSON

Reimplemented from fc::exception.

Definition at line 345 of file exception.cpp.

346 {
347 if( !(_inner == std::exception_ptr()) ) std::rethrow_exception( _inner );
349 }
virtual NO_RETURN void dynamic_rethrow_exception() const
Here is the call graph for this function:

◆ from_current_exception()

std_exception_wrapper fc::std_exception_wrapper::from_current_exception ( const std::exception & e)
static

Definition at line 335 of file exception.cpp.

336 {
337 return std_exception_wrapper{FC_LOG_MESSAGE(warn, "rethrow ${what}: ", ("what",e.what())),
338 std::current_exception(),
339 BOOST_CORE_TYPEID(e).name(),
340 e.what()};
341 }
std_exception_wrapper(log_message &&m, std::exception_ptr e=std::current_exception(), const std::string &name_value="exception", const std::string &what_value="unspecified")
#define FC_LOG_MESSAGE(LOG_LEVEL, FORMAT,...)
A helper method for generating log messages.
Here is the caller graph for this function:

◆ get_inner_exception()

std::exception_ptr fc::std_exception_wrapper::get_inner_exception ( ) const

Definition at line 343 of file exception.cpp.

343{ return _inner; }

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