diff options
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/assert.h | 13 | ||||
-rw-r--r-- | src/lib/utils/exceptn.h | 10 |
2 files changed, 21 insertions, 2 deletions
diff --git a/src/lib/utils/assert.h b/src/lib/utils/assert.h index f80f9b170..c49ae62ee 100644 --- a/src/lib/utils/assert.h +++ b/src/lib/utils/assert.h @@ -35,6 +35,19 @@ BOTAN_NORETURN void BOTAN_DLL assertion_failure(const char* expr_str, } while(0) /** +* Make an assertion +*/ +#define BOTAN_ASSERT_NOMSG(expr) \ + do { \ + if(!(expr)) \ + Botan::assertion_failure(#expr, \ + "", \ + BOTAN_CURRENT_FUNCTION, \ + __FILE__, \ + __LINE__); \ + } while(0) + +/** * Assert that value1 == value2 */ #define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made) \ diff --git a/src/lib/utils/exceptn.h b/src/lib/utils/exceptn.h index 193d78ce9..a3cb11f81 100644 --- a/src/lib/utils/exceptn.h +++ b/src/lib/utils/exceptn.h @@ -29,14 +29,20 @@ class BOTAN_DLL Exception : public std::exception }; /** -* An invalid argument which caused +* An invalid argument */ class BOTAN_DLL Invalid_Argument : public Exception { public: explicit Invalid_Argument(const std::string& msg) : Exception("Invalid argument", msg) {} - }; + + explicit Invalid_Argument(const std::string& msg, const std::string& where) : + Exception("Invalid argument", msg + " in " + where) {} +}; + +#define BOTAN_ARG_CHECK(expr) \ + do { if(!(expr)) throw Invalid_Argument(#expr, BOTAN_CURRENT_FUNCTION); } while(0) /** * Unsupported_Argument Exception |