diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
commit | f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 (patch) | |
tree | 49e44c6f87febed37efb953ab5485aa49f6481a7 /src/lib/exceptions/isc_assert.h | |
parent | Initial commit. (diff) | |
download | isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.tar.xz isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.zip |
Adding upstream version 2.4.1.upstream/2.4.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/exceptions/isc_assert.h')
-rw-r--r-- | src/lib/exceptions/isc_assert.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/exceptions/isc_assert.h b/src/lib/exceptions/isc_assert.h new file mode 100644 index 0000000..6b5bf95 --- /dev/null +++ b/src/lib/exceptions/isc_assert.h @@ -0,0 +1,28 @@ +// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef ISC_ASSERT_H +#define ISC_ASSERT_H + +#include <exceptions/exceptions.h> + +namespace isc { + +/// @brief Replacement for assert() that throws if the expression is false. +/// This macro exists because some of the original code uses assert() and we +/// decided it would be better to replace them with exception throws rather +/// than compiling out all asserts. +#define isc_throw_assert(expr) \ +{\ + if(!(static_cast<bool>(expr))) \ + {\ + isc_throw(isc::Unexpected, __FILE__ << ":" << __LINE__ << " (" << #expr << ") failed");\ + }\ +} + +} + +#endif // ISC_ASSERT_H |