Chi-Tech
chi_log_exceptions.h
Go to the documentation of this file.
1#ifndef CHITECH_CHI_LOG_EXCEPTIONS_H
2#define CHITECH_CHI_LOG_EXCEPTIONS_H
3
4#include <string>
5#include <stdexcept>
6
7#define ChiInvalidArgumentIf(condition, message) \
8 if (condition) \
9 throw std::invalid_argument(std::string(__PRETTY_FUNCTION__) + ": " + \
10 message)
11#define ChiInvalidArgument(message) \
12 throw std::invalid_argument(std::string(__PRETTY_FUNCTION__) + ": " + \
13 message)
14
15#define ChiLogicalErrorIf(condition, message) \
16 if (condition) \
17 throw std::logic_error(std::string(__PRETTY_FUNCTION__) + ": " + message)
18
19#define ChiLogicalError(message) \
20 throw std::logic_error(std::string(__PRETTY_FUNCTION__) + ": " + message)
21
22#define ChiRecoverableInvalidArgument(condition, message) \
23 { \
24 if (condition) \
25 throw std::RecoverableException( \
26 std::string("Recoverable Invalid Argument: "), \
27 std::string(__PRETTY_FUNCTION__) + ": " + #message); \
28 }
29
30#define ChiRecoverableLogicalError(condition, message) \
31 { \
32 if (condition) \
33 throw std::RecoverableException(std::string("Recoverable Logic Error: ") \
34 std::string(__PRETTY_FUNCTION__) + \
35 ": " + #message); \
36 }
37
38#endif // CHITECH_CHI_LOG_EXCEPTIONS_H