Skip to content

Commit

Permalink
Moved std::terminate into the contract handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
kgorking committed Nov 8, 2023
1 parent 43abe80 commit ca8f738
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/ecs/detail/contract.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ struct default_contract_violation_impl {
std::cerr << why << ": \"" << how << "\"\n\t" << what << "\n\n";
#ifdef __cpp_lib_stacktrace
// Dump a stack trace if available
std::cerr << "** Stackdump **\n" << std::stacktrace::current(3) << '\n';
std::cerr << "** stack dump **\n" << std::stacktrace::current(3) << '\n';
#endif
std::terminate();
}

void assertion_failed(char const* what, char const* how) noexcept {
Expand Down Expand Up @@ -51,23 +52,20 @@ template <typename... DummyArgs>
inline void do_assertion_failed(char const* what, char const* how) noexcept {
ecs::detail::contract_violation_interface auto& cvi = contract_violation_handler<DummyArgs...>;
cvi.assertion_failed(what, how);
std::terminate();
}

template <typename... DummyArgs>
requires(sizeof...(DummyArgs) == 0)
inline void do_precondition_violation(char const* what, char const* how) noexcept {
ecs::detail::contract_violation_interface auto& cvi = contract_violation_handler<DummyArgs...>;
cvi.precondition_violation(what, how);
std::terminate();
}

template <typename... DummyArgs>
requires(sizeof...(DummyArgs) == 0)
inline void do_postcondition_violation(char const* what, char const* how) noexcept {
ecs::detail::contract_violation_interface auto& cvi = contract_violation_handler<DummyArgs...>;
cvi.postcondition_violation(what, how);
std::terminate();
}
} // namespace ecs::detail

Expand Down

0 comments on commit ca8f738

Please sign in to comment.