mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 02:02:38 +01:00
ircd: Add assertion() overload taking message string.
This commit is contained in:
parent
37b55e4b11
commit
ca11351692
2 changed files with 22 additions and 6 deletions
|
@ -32,6 +32,7 @@ namespace ircd
|
|||
// Terminates in debug mode; throws in release mode; always logs critical.
|
||||
[[noreturn]] void assertion(const std::exception &) noexcept(RB_DEBUG_LEVEL);
|
||||
[[noreturn]] void assertion(std::exception_ptr) noexcept(RB_DEBUG_LEVEL);
|
||||
[[noreturn]] void assertion(const string_view &) noexcept(RB_DEBUG_LEVEL);
|
||||
[[noreturn]] void assertion() noexcept(RB_DEBUG_LEVEL);
|
||||
|
||||
// util
|
||||
|
|
|
@ -181,16 +181,31 @@ void
|
|||
ircd::assertion()
|
||||
noexcept(RB_DEBUG_LEVEL)
|
||||
{
|
||||
static const auto &default_message
|
||||
{
|
||||
"without exception"_sv
|
||||
};
|
||||
|
||||
assertion(default_message);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::assertion(const string_view &msg)
|
||||
noexcept(RB_DEBUG_LEVEL)
|
||||
{
|
||||
log::critical
|
||||
{
|
||||
"IRCd Assertion :%s", msg
|
||||
};
|
||||
|
||||
if(std::uncaught_exceptions())
|
||||
assertion(std::current_exception());
|
||||
|
||||
log::critical
|
||||
{
|
||||
"IRCd Assertion without exception."
|
||||
};
|
||||
|
||||
assert(0);
|
||||
throw assertive{};
|
||||
throw assertive
|
||||
{
|
||||
"IRCd Assertion :%s", msg
|
||||
};
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue