BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
Go to the documentation of this file.
2 #include <boost/exception/all.hpp>
31 (file_not_found_exception)
32 (parse_error_exception)
33 (invalid_arg_exception)
34 (invalid_operation_exception)
35 (key_not_found_exception)
37 (out_of_range_exception)
41 (unknown_host_exception)
46 (divide_by_zero_exception)
61 const std::string& name_value,
62 const std::string& what_value )
63 :my( new detail::exception_impl() )
66 my->_what = what_value;
67 my->_name = name_value;
68 my->_elog = std::move(msgs);
74 const std::string& name_value,
75 const std::string& what_value )
76 :my( new detail::exception_impl() )
79 my->_what = what_value;
80 my->_name = name_value;
95 {
my->_elog = std::move(m); }
107 auto e = std::make_shared<unhandled_exception>( *
this );
113 const std::string& name_value,
114 const std::string& what_value )
115 :my( new detail::exception_impl() )
118 my->_what = what_value;
119 my->_name = name_value;
124 const std::string& name_value,
125 const std::string& what_value )
126 :my( new detail::exception_impl() )
129 my->_what = what_value;
130 my->_name = name_value;
131 my->_elog.push_back( std::move( msg ) );
134 :my( new detail::exception_impl(*c.my) )
137 :my(
std::move(c.my) ){}
147 FC_ASSERT( max_depth > 0,
"Recursion depth exceeded!" );
151 tmp(
"code", e.
code() )
153 (
"message", e.
what() )
160 FC_ASSERT( max_depth > 0,
"Recursion depth exceeded!" );
162 if( obj.contains(
"stack" ) )
164 if( obj.contains(
"code" ) )
165 ll.
my->_code = obj[
"code"].as_int64();
166 if( obj.contains(
"name" ) )
167 ll.
my->_name = obj[
"name"].as_string();
168 if( obj.contains(
"message" ) )
169 ll.
my->_what = obj[
"message"].as_string();
175 my->_elog.emplace_back( std::move(m) );
185 std::stringstream ss;
189 }
catch( std::bad_alloc& ) {
192 ss <<
"<- exception in to_detail_string.";
194 ss <<
" " <<
my->_name <<
": " <<
my->_what <<
"\n";
195 for(
auto itr =
my->_elog.begin(); itr !=
my->_elog.end(); )
198 ss << itr->get_message() <<
"\n";
203 catch(
const fc::assert_exception& e )
205 ss <<
"ERROR: Failed to convert log data to string!\n";
207 ss <<
" " << itr->get_context().to_string();
208 }
catch( std::bad_alloc& ) {
211 ss <<
"<- exception in to_detail_string.";
214 if( itr !=
my->_elog.end() ) ss<<
"\n";
216 }
catch( std::bad_alloc& ) {
219 ss <<
"<- exception in to_detail_string.\n";
229 std::stringstream ss;
232 for(
auto itr =
my->_elog.begin(); itr !=
my->_elog.end(); ++itr ) {
233 if( itr->get_format().size() )
236 }
catch( std::bad_alloc& ) {
239 ss <<
"<- exception in to_string.\n";
242 }
catch( std::bad_alloc& ) {
245 ss <<
"<- exception in to_string.\n";
252 auto itr = _registered_exceptions.find( e.
code() );
253 if( itr != _registered_exceptions.end() )
254 itr->second->rethrow( e );
269 return std::make_shared<exception>(*
this);
274 return boost::current_exception_diagnostic_information();
280 "invalid index '${key}' in enum '${enum}'",
281 (
"key",i)(
"enum",e) );
286 "invalid name '${key}' in enum '${enum}'",
287 (
"key",k)(
"enum",e) );
293 throw null_optional();
314 const char* filename,
321 (
"source_file", filename)
322 (
"source_lineno", lineno)
328 <<
"FC_ASSERT triggered: "
331 catch(
const fc::assert_exception& e )
333 std::cout <<
"ERROR: Failed to convert info to string?!\n";
@ file_not_found_exception_code
void copy(const path &from, const path &to)
bool assert_optional(bool is_valid)
virtual void dynamic_rethrow_exception() const
Used to generate a useful error report when an exception is thrown.
An order-perserving dictionary of variant's.
unhandled_exception(log_message &&m, std::exception_ptr e=std::current_exception())
std::exception_ptr get_inner_exception() const
const log_messages & get_log() const
@ invalid_arg_exception_code
@ unknown_host_exception_code
void append_log(log_message m)
virtual const char * what() const
std::string as_string() const
@ bad_cast_exception_code
bool enable_record_assert_trip
void from_variant(const variant &var, flat_set< T, A... > &vo, uint32_t _max_depth)
std::shared_ptr< exception > exception_ptr
static string to_string(const variant &v, output_formatting format=stringify_large_ints_and_doubles, uint32_t max_depth=DEFAULT_MAX_RECURSION_DEPTH)
@ invalid_operation_exception_code
#define FC_REGISTER_EXCEPTIONS(SEQ)
void throw_assertion_failure(const std::string &message)
exception(int64_t code=unspecified_exception_code, const std::string &name_value="exception", const std::string &what_value="unspecified")
const char * name() const
static exception_factory & instance()
std::string to_string(log_level ll=log_level::info) const
void record_assert_trip(const char *filename, uint32_t lineno, const char *expr)
std::unique_ptr< detail::exception_impl > my
virtual void dynamic_rethrow_exception() const
void to_variant(const flat_set< T, A... > &var, variant &vo, uint32_t _max_depth)
@ key_not_found_exception_code
std::string to_detail_string(log_level ll=log_level::all) const
virtual std::shared_ptr< exception > dynamic_copy_exception() const
std::string format_string(const std::string &, const variant_object &, uint32_t max_object_depth=200)
() 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() aes_exception() overflow_exception() underflow_exception(divide_by_zero_exception)) namespace detail
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
aggregates a message along with the context and associated meta-information.
variant_object & get_object()
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Defines exception's used by fc.
std::vector< log_message > log_messages
@ canceled_exception_code
@ parse_error_exception_code
@ method_not_found_exception_code
void rethrow(const exception &e) const
FC_IMPLEMENT_EXCEPTION(method_not_found_exception, method_not_found_exception_code, "Method Not Found")
@ timeout_exception_code
timeout exceptions
exception & operator=(const exception ©)
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
@ out_of_range_exception_code
void throw_bad_enum_cast(int64_t i, const char *e)
virtual std::shared_ptr< exception > dynamic_copy_exception() const