0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-17 09:28:21 +02:00

ircd: Utils for std::system_error related; minor cleanup.

This commit is contained in:
Jason Volk 2018-01-10 21:32:32 -08:00
parent f76d6e3f1d
commit c4ea3cc3e3
2 changed files with 30 additions and 14 deletions

View file

@ -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;
}

View file

@ -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);
}