aboutsummaryrefslogtreecommitdiffstats
path: root/libdevcore/Assertions.h
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-01-06 22:17:16 +0800
committerchriseth <c@ethdev.com>2017-01-13 00:52:26 +0800
commita3b01eca27b19311a05b9c7b7e2ed8eb51b0e51c (patch)
tree2e20b03b699c0cd06fddc7345dd2d9393250a5a2 /libdevcore/Assertions.h
parent652d8dab191fcd50ce59b049177ae3281255f309 (diff)
downloaddexon-solidity-a3b01eca27b19311a05b9c7b7e2ed8eb51b0e51c.tar.gz
dexon-solidity-a3b01eca27b19311a05b9c7b7e2ed8eb51b0e51c.tar.zst
dexon-solidity-a3b01eca27b19311a05b9c7b7e2ed8eb51b0e51c.zip
Do not evaluate strings if assertion succeeds.
Diffstat (limited to 'libdevcore/Assertions.h')
-rw-r--r--libdevcore/Assertions.h32
1 files changed, 12 insertions, 20 deletions
diff --git a/libdevcore/Assertions.h b/libdevcore/Assertions.h
index 05e0b0e5..0fb5837c 100644
--- a/libdevcore/Assertions.h
+++ b/libdevcore/Assertions.h
@@ -73,27 +73,19 @@ inline bool assertEqualAux(A const& _a, B const& _b, char const* _aStr, char con
/// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong.");
/// Do NOT supply an exception object as the second parameter.
#define assertThrow(_condition, _ExceptionType, _description) \
- ::dev::assertThrowAux<_ExceptionType>(!!(_condition), _description, __LINE__, __FILE__, ETH_FUNC)
+ do \
+ { \
+ if (!(_condition)) \
+ ::boost::throw_exception( \
+ _ExceptionType() << \
+ ::dev::errinfo_comment(_description) << \
+ ::boost::throw_function(ETH_FUNC) << \
+ ::boost::throw_file(__FILE__) << \
+ ::boost::throw_line(__LINE__) \
+ ); \
+ } \
+ while (false)
using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
-template <class _ExceptionType>
-inline void assertThrowAux(
- bool _condition,
- ::std::string const& _errorDescription,
- unsigned _line,
- char const* _file,
- char const* _function
-)
-{
- if (!_condition)
- ::boost::throw_exception(
- _ExceptionType() <<
- ::dev::errinfo_comment(_errorDescription) <<
- ::boost::throw_function(_function) <<
- ::boost::throw_file(_file) <<
- ::boost::throw_line(_line)
- );
-}
-
}