forked from lthn/blockchain
crypto_assert re-implemented using exceptions
This commit is contained in:
parent
4028bab31c
commit
03f949b669
3 changed files with 6 additions and 7 deletions
|
|
@ -16,10 +16,6 @@ namespace crypto
|
|||
#include "crypto/crypto-ops.h"
|
||||
} // extern "C"
|
||||
|
||||
#define CRYPTO_STR_(X) #X
|
||||
#define CRYPTO_STR(X) CRYPTO_STR_(X)
|
||||
#define CRYPTO_CHECK_AND_THROW_MES(cond, msg) if (!(cond)) { throw std::runtime_error(msg " @ " __FILE__ ":" CRYPTO_STR(__LINE__)); }
|
||||
|
||||
//
|
||||
// Helpers
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2022 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#include "hash.h"
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
# define crypto_assert(expression) assert(expression)
|
||||
# define crypto_assert(expression) assert(expression); CRYPTO_CHECK_AND_THROW_MES(expression, #expression)
|
||||
#else
|
||||
# define crypto_assert(expression) ((void)0)
|
||||
# define crypto_assert(expression) CRYPTO_CHECK_AND_THROW_MES(expression, #expression)
|
||||
#endif
|
||||
|
||||
namespace crypto {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@
|
|||
#include "hash.h"
|
||||
#include "warnings.h"
|
||||
|
||||
#define CRYPTO_STR_(X) #X
|
||||
#define CRYPTO_STR(X) CRYPTO_STR_(X)
|
||||
#define CRYPTO_CHECK_AND_THROW_MES(cond, msg) if (!(cond)) { throw std::runtime_error(msg " @ " __FILE__ ":" CRYPTO_STR(__LINE__)); }
|
||||
|
||||
PUSH_GCC_WARNINGS
|
||||
DISABLE_CLANG_WARNING(unused-private-field)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue