Add default messages to assertion macros

This commit is contained in:
Kamil Śliwak 2021-09-23 16:26:35 +02:00 committed by chriseth
parent 1f087ce15c
commit 4fe6aa1328
4 changed files with 6 additions and 6 deletions

View File

@ -47,16 +47,16 @@ struct InvalidAstError: virtual util::Exception {};
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
#define solAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::solidity::langutil::InternalCompilerError, DESCRIPTION)
assertThrowWithDefaultDescription(CONDITION, ::solidity::langutil::InternalCompilerError, DESCRIPTION, "Solidity assertion failed")
#define solUnimplementedAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::solidity::langutil::UnimplementedFeatureError, DESCRIPTION)
assertThrowWithDefaultDescription(CONDITION, ::solidity::langutil::UnimplementedFeatureError, DESCRIPTION, "Unimplemented feature")
#define solUnimplemented(DESCRIPTION) \
solUnimplementedAssert(false, DESCRIPTION)
#define astAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::solidity::langutil::InvalidAstError, DESCRIPTION)
assertThrowWithDefaultDescription(CONDITION, ::solidity::langutil::InvalidAstError, DESCRIPTION, "AST assertion failed")
using errorSourceLocationInfo = std::pair<std::string, SourceLocation>;

View File

@ -27,6 +27,6 @@ namespace solidity::smtutil
struct SMTLogicError: virtual util::Exception {};
#define smtAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, SMTLogicError, DESCRIPTION)
assertThrowWithDefaultDescription(CONDITION, SMTLogicError, DESCRIPTION, "SMT assertion failed")
}

View File

@ -77,6 +77,6 @@ inline std::string stringOrDefault(std::string _string, std::string _defaultStri
/// Use it as assertThrow(1 == 1, ExceptionType, "Mathematics is wrong.");
/// The second parameter must be an exception class (rather than an instance).
#define assertThrow(_condition, _exceptionType, _description) \
assertThrowWithDefaultDescription(_condition, _exceptionType, _description, "")
assertThrowWithDefaultDescription(_condition, _exceptionType, _description, "Assertion failed")
}

View File

@ -53,6 +53,6 @@ struct StackTooDeepError: virtual YulException
/// Assertion that throws an YulAssertion containing the given description if it is not met.
#define yulAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::solidity::yul::YulAssertion, DESCRIPTION)
assertThrowWithDefaultDescription(CONDITION, ::solidity::yul::YulAssertion, DESCRIPTION, "Yul assertion failed")
}