[ox/std] Make ox::make handle std::exception to report what()

This commit is contained in:
Gary Talent 2023-08-09 00:01:17 -05:00
parent ead3fd39c4
commit da6eb40966

View File

@ -41,8 +41,11 @@ constexpr T *make(Args &&...args) noexcept {
#ifdef __cpp_exceptions #ifdef __cpp_exceptions
try { try {
return new T(ox::forward<Args>(args)...); return new T(ox::forward<Args>(args)...);
} catch (std::exception const&ex) {
oxPanic(OxError(1, ex.what()), ex.what());
return nullptr;
} catch (...) { } catch (...) {
oxPanic(OxError(1, "Allocation or constructor failed"), "Allocation or constructor failed"); oxPanic(OxError(2, "Allocation or constructor failed"), "Allocation or constructor failed");
return nullptr; return nullptr;
} }
#else #else