mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add default messages to assertion macros
This commit is contained in:
parent
1f087ce15c
commit
4fe6aa1328
@ -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>;
|
||||
|
||||
|
@ -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")
|
||||
|
||||
}
|
||||
|
@ -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")
|
||||
|
||||
}
|
||||
|
@ -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")
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user