Merge branch 'master' of https://github.com/cryptonomex/fc
This commit is contained in:
commit
8d13f292b8
2 changed files with 34 additions and 1 deletions
|
|
@ -6,9 +6,9 @@
|
|||
#include <fc/log/logger.hpp>
|
||||
#include <fc/optional.hpp>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
||||
|
||||
namespace fc
|
||||
{
|
||||
namespace detail { class exception_impl; }
|
||||
|
|
@ -292,6 +292,13 @@ namespace fc
|
|||
|
||||
std::string except_str();
|
||||
|
||||
void record_assert_trip(
|
||||
const char* filename,
|
||||
uint32_t lineno,
|
||||
const char* expr
|
||||
);
|
||||
|
||||
extern bool enable_record_assert_trip;
|
||||
} // namespace fc
|
||||
|
||||
#if __APPLE__
|
||||
|
|
@ -313,7 +320,11 @@ namespace fc
|
|||
FC_EXPAND_MACRO( \
|
||||
FC_MULTILINE_MACRO_BEGIN \
|
||||
if( UNLIKELY(!(TEST)) ) \
|
||||
{ \
|
||||
if( fc::enable_record_assert_trip ) \
|
||||
fc::record_assert_trip( __FILE__, __LINE__, #TEST ); \
|
||||
FC_THROW_EXCEPTION( fc::assert_exception, #TEST ": " __VA_ARGS__ ); \
|
||||
} \
|
||||
FC_MULTILINE_MACRO_END \
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include <fc/log/logger.hpp>
|
||||
#include <fc/io/json.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace fc
|
||||
{
|
||||
FC_REGISTER_EXCEPTIONS( (timeout_exception)
|
||||
|
|
@ -228,4 +230,24 @@ namespace fc
|
|||
return *this;
|
||||
}
|
||||
|
||||
void record_assert_trip(
|
||||
const char* filename,
|
||||
uint32_t lineno,
|
||||
const char* expr
|
||||
)
|
||||
{
|
||||
fc::mutable_variant_object assert_trip_info =
|
||||
fc::mutable_variant_object()
|
||||
("source_file", filename)
|
||||
("source_lineno", lineno)
|
||||
("expr", expr)
|
||||
;
|
||||
std::cout
|
||||
<< "FC_ASSERT triggered: "
|
||||
<< fc::json::to_string( assert_trip_info ) << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
bool enable_record_assert_trip = false;
|
||||
|
||||
} // fc
|
||||
|
|
|
|||
Loading…
Reference in a new issue