mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 01:30:12 +01:00
ircd: Utils for std::system_error related; minor cleanup.
This commit is contained in:
parent
f76d6e3f1d
commit
c4ea3cc3e3
2 changed files with 30 additions and 14 deletions
|
@ -41,6 +41,10 @@ namespace ircd
|
|||
[[noreturn]] void assertion(std::exception_ptr) noexcept(RB_DEBUG);
|
||||
[[noreturn]] void assertion() noexcept(RB_DEBUG);
|
||||
|
||||
// util
|
||||
std::exception_ptr make_system_error(const int &code = errno);
|
||||
[[noreturn]] void throw_system_error(const int &code = errno);
|
||||
|
||||
// Can be used to clobber the std::terminate_handler
|
||||
void aborting() noexcept;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,32 @@
|
|||
*
|
||||
*/
|
||||
|
||||
[[noreturn]] static void
|
||||
ircd_terminate_handler()
|
||||
noexcept
|
||||
{
|
||||
std::abort();
|
||||
}
|
||||
|
||||
void
|
||||
ircd::aborting()
|
||||
noexcept
|
||||
{
|
||||
std::set_terminate(&ircd_terminate_handler);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::throw_system_error(const int &code)
|
||||
{
|
||||
throw std::system_error(code, std::system_category());
|
||||
}
|
||||
|
||||
std::exception_ptr
|
||||
ircd::make_system_error(const int &code)
|
||||
{
|
||||
return std::make_exception_ptr(std::system_error(code, std::system_category()));
|
||||
}
|
||||
|
||||
ssize_t
|
||||
ircd::exception::generate(const char *const &fmt,
|
||||
const va_rtti &ap)
|
||||
|
@ -116,17 +142,3 @@ noexcept
|
|||
log::critical("IRCd Terminated: %s", e.what());
|
||||
throw e;
|
||||
}
|
||||
|
||||
[[noreturn]] static void
|
||||
ircd_terminate_handler()
|
||||
noexcept
|
||||
{
|
||||
std::abort();
|
||||
}
|
||||
|
||||
void
|
||||
ircd::aborting()
|
||||
noexcept
|
||||
{
|
||||
std::set_terminate(&ircd_terminate_handler);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue