2#include <boost/exception/all.hpp>
11 (file_not_found_exception)
12 (parse_error_exception)
13 (invalid_arg_exception)
14 (invalid_operation_exception)
15 (key_not_found_exception)
17 (out_of_range_exception)
21 (unknown_host_exception)
27 (divide_by_zero_exception)
42 const std::string& name_value,
43 const std::string& what_value )
44 :my( new
detail::exception_impl() )
47 my->_what = what_value;
48 my->_name = name_value;
49 my->_elog = fc::move(msgs);
55 const std::string& name_value,
56 const std::string& what_value )
57 :my( new
detail::exception_impl() )
60 my->_what = what_value;
61 my->_name = name_value;
76 {
my->_elog = fc::move(m); }
82 if( !(_inner == std::exception_ptr()) ) std::rethrow_exception( _inner );
88 auto e = std::make_shared<unhandled_exception>( *
this );
94 const std::string& name_value,
95 const std::string& what_value )
96 :my( new
detail::exception_impl() )
99 my->_what = what_value;
100 my->_name = name_value;
105 const std::string& name_value,
106 const std::string& what_value )
107 :my( new
detail::exception_impl() )
110 my->_what = what_value;
111 my->_name = name_value;
112 my->_elog.push_back( fc::move( msg ) );
115 :my( new
detail::exception_impl(*c.my) )
118 :my(
fc::move(c.my) ){}
130 (
"message", e.
what() )
137 if( obj.contains(
"stack" ) )
139 if( obj.contains(
"code" ) )
140 ll.
my->_code = obj[
"code"].as_int64();
141 if( obj.contains(
"name" ) )
142 ll.
my->_name = obj[
"name"].as_string();
143 if( obj.contains(
"message" ) )
144 ll.
my->_what = obj[
"message"].as_string();
150 my->_elog.emplace_back( fc::move(m) );
161 std::stringstream ss;
165 }
catch( std::bad_alloc& ) {
168 ss <<
"<- exception in to_detail_string.";
170 ss <<
" " <<
my->_name <<
": " <<
my->_what <<
"\n";
171 for(
auto itr =
my->_elog.begin(); itr !=
my->_elog.end(); ++itr ) {
173 ss << itr->get_message() <<
"\n";
175 ss <<
" " << itr->get_context().to_string() <<
"\n";
176 }
catch( std::bad_alloc& ) {
178 }
catch(
const fc::timeout_exception& e) {
179 ss <<
"<- timeout exception in to_detail_string: " << e.what() <<
"\n";
182 ss <<
"<- exception in to_detail_string.\n";
185 }
catch( std::bad_alloc& ) {
188 ss <<
"<- exception in to_detail_string.\n";
199 std::stringstream ss;
204 }
catch( std::bad_alloc& ) {
207 ss <<
"<- exception in to_string.\n";
209 for(
auto itr =
my->_elog.begin(); itr !=
my->_elog.end(); ++itr ) {
214 }
catch( std::bad_alloc& ) {
216 }
catch(
const fc::timeout_exception& e) {
217 ss <<
"<- timeout exception in to_string: " << e.what();
220 ss <<
"<- exception in to_string.\n";
224 }
catch( std::bad_alloc& ) {
227 ss <<
"<- exception in to_string.\n";
237 for(
auto itr =
my->_elog.begin(); itr !=
my->_elog.end(); ++itr )
249 auto itr = _registered_exceptions.find( e.
code() );
250 if( itr != _registered_exceptions.end() )
251 itr->second->rethrow( e );
266 return std::make_shared<exception>(*
this);
271 return boost::current_exception_diagnostic_information();
277 "invalid index '${key}' in enum '${enum}'",
278 (
"key",i)(
"enum",e) );
283 "invalid name '${key}' in enum '${enum}'",
284 (
"key",k)(
"enum",e) );
290 throw null_optional();
306 const char* filename,
313 (
"source_file", filename)
314 (
"source_lineno", lineno)
328 const std::string& name_value,
329 const std::string& what_value)
332 _inner = {std::move(e)};
338 std::current_exception(),
339 BOOST_CORE_TYPEID(e).name(),
347 if( !(_inner == std::exception_ptr()) ) std::rethrow_exception( _inner );
353 auto e = std::make_shared<std_exception_wrapper>( *
this );
void NO_RETURN rethrow(const exception &e) const
static exception_factory & instance()
Used to generate a useful error report when an exception is thrown.
static constexpr fc::microseconds format_time_limit
virtual std::shared_ptr< exception > dynamic_copy_exception() const
exception(int64_t code=unspecified_exception_code, const std::string &name_value="exception", const std::string &what_value="unspecified")
void append_log(log_message m)
const log_messages & get_log() const
std::string to_detail_string(log_level ll=log_level::all) const
std::unique_ptr< detail::exception_impl > my
const char * name() const
const char * what() const noexcept override
virtual NO_RETURN void dynamic_rethrow_exception() const
std::string to_string(log_level ll=log_level::info) const
std::string top_message() const
exception & operator=(const exception ©)
static string to_string(const variant &v, const yield_function_t &yield, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
aggregates a message along with the context and associated meta-information.
An order-preserving dictionary of variants.
wrapper for std::exception
virtual std::shared_ptr< exception > dynamic_copy_exception() const
virtual NO_RETURN void dynamic_rethrow_exception() const
std::exception_ptr get_inner_exception() const
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")
static std_exception_wrapper from_current_exception(const std::exception &e)
unhandled_exception(log_message &&m, std::exception_ptr e=std::current_exception())
virtual std::shared_ptr< exception > dynamic_copy_exception() const
virtual NO_RETURN void dynamic_rethrow_exception() const
std::exception_ptr get_inner_exception() const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
variant_object & get_object()
Defines exception's used by fc.
#define FC_CHECK_DEADLINE(DEADLINE,...)
#define FC_REGISTER_EXCEPTIONS(SEQ)
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
#define FC_LOG_MESSAGE(LOG_LEVEL, FORMAT,...)
A helper method for generating log messages.
std::shared_ptr< exception > exception_ptr
bool enable_record_assert_trip
void record_assert_trip(const char *filename, uint32_t lineno, const char *expr)
bool assert_optional(bool is_valid)
std::vector< log_message > log_messages
void throw_bad_enum_cast(int64_t i, const char *e)
void copy(const path &from, const path &to)
file_not_found_exception parse_error_exception invalid_arg_exception invalid_operation_exception key_not_found_exception bad_cast_exception out_of_range_exception canceled_exception assert_exception eof_exception unknown_host_exception null_optional udt_exception aes_exception overflow_exception underflow_exception(divide_by_zero_exception)) namespace detail
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
fc::string format_string(const fc::string &, const variant_object &, bool minimize=false)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)