Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/catch2/internal/catch_enforce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <catch2/internal/catch_stdstreams.hpp>

#include <stdexcept>
#include <system_error>


namespace Catch {
Expand Down Expand Up @@ -36,6 +37,11 @@ namespace Catch {
throw_exception(std::runtime_error(msg));
}

[[noreturn]]
void throw_system_error(int ev, const std::error_category& ecat) {
throw_exception(std::system_error(ev, ecat));
}



} // namespace Catch;
5 changes: 5 additions & 0 deletions src/catch2/internal/catch_enforce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace Catch {
void throw_domain_error(std::string const& msg);
[[noreturn]]
void throw_runtime_error(std::string const& msg);
[[noreturn]]
void throw_system_error(int ev, const std::error_category& ecat);

} // namespace Catch;

Expand All @@ -47,6 +49,9 @@ namespace Catch {
#define CATCH_RUNTIME_ERROR(...) \
Catch::throw_runtime_error(CATCH_MAKE_MSG( __VA_ARGS__ ))

#define CATCH_SYSTEM_ERROR(ev, ecat) \
Catch::throw_system_error((ev), (ecat))

#define CATCH_ENFORCE( condition, ... ) \
do{ if( !(condition) ) CATCH_ERROR( __VA_ARGS__ ); } while(false)

Expand Down
Loading