Added generic throw_ and throw_msg macros
This commit is contained in:
parent
1fa34dd16c
commit
6865d04377
@ -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};
|
||||
}
|
||||
|
@ -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_() __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_msg(___msg___) __throw___(__FILE__, __LINE__, ___msg___);
|
||||
|
||||
#endif /* defined(__throw__) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user