diff --git a/src/throw.cpp b/src/throw.cpp index 74b34e8..9382655 100644 --- a/src/throw.cpp +++ b/src/throw.cpp @@ -63,3 +63,8 @@ void __throw_if_err(int err, throw system_error {ec, msg}; } } + +void __throw___(const char* file, unsigned int line, const char* message) { + string msg {combine_message_elements(file, line, message, "")}; + throw runtime_error {msg}; +} diff --git a/src/throw.hpp b/src/throw.hpp index c34a016..dc27fa7 100644 --- a/src/throw.hpp +++ b/src/throw.hpp @@ -9,13 +9,16 @@ void __throw_if_min1(int x, const char* file, unsigned int line, const char* message = nullptr); void __throw_if_null(const void* p, const char* file, unsigned int line, const char* message = nullptr); void __throw_if_err(int err, const char* file, unsigned int line, const char* message = nullptr); +void __throw___(const char* file, unsigned int line, const char* message = nullptr); -#define throw_if_min1(___x___) __throw_if_min1((___x___), __FILE__, __LINE__) -#define throw_if_null(__ptr__) __throw_if_null((__ptr__), __FILE__, __LINE__) -#define throw_if_err(__err__) __throw_if_err((__err__), __FILE__, __LINE__) +#define throw_if_min1(___x___) __throw_if_min1((___x___), __FILE__, __LINE__) +#define throw_if_null(__ptr__) __throw_if_null((__ptr__), __FILE__, __LINE__) +#define throw_if_err(__err__) __throw_if_err((__err__), __FILE__, __LINE__) +#define throw_() __throw___(__FILE__, __LINE__); -#define throw_if_min1_msg(___x___, ___msg___) __throw_if_min1((___x___), __FILE__, __LINE__, ___msg___) -#define throw_if_null_msg(__ptr__, ___msg___) __throw_if_null((__ptr__), __FILE__, __LINE__, ___msg___) -#define throw_if_err_msg(__err__, ___msg___) __throw_if_err((__err__), __FILE__, __LINE__, ___msg___) +#define throw_if_min1_msg(___x___, ___msg___) __throw_if_min1((___x___), __FILE__, __LINE__, ___msg___) +#define throw_if_null_msg(__ptr__, ___msg___) __throw_if_null((__ptr__), __FILE__, __LINE__, ___msg___) +#define throw_if_err_msg(__err__, ___msg___) __throw_if_err((__err__), __FILE__, __LINE__, ___msg___) +#define throw_msg(___msg___) __throw___(__FILE__, __LINE__, ___msg___); #endif /* defined(__throw__) */