11 #ifndef _UGCS_VSM_EXCEPTION_H_
12 #define _UGCS_VSM_EXCEPTION_H_
57 Exception(Va_list_overload, const
char *msg, va_list args)
__FORMAT(printf, 3, 0);
65 what() const noexcept
override
85 template <
typename Dummy =
void,
typename TParam =
int>
132 template <
class Base_exception,
typename Dummy =
void>
136 template <
typename... Args>
138 Base_exception(std::forward<Args>(args)...)
149 #define VSM_EXCEPTION(__exc_class, __msg, ...) \
150 throw __exc_class(__exc_class::Va_args_overload(), "[%s:%d] " __msg, __FILE__, __LINE__, ## __VA_ARGS__)
158 #define VSM_PARAM_EXCEPTION(__exc_class, __param, __msg, ...) \
159 throw __exc_class(__exc_class::Va_args_overload(), __param, "[%s:%d] " __msg, __FILE__, __LINE__, ## __VA_ARGS__)
168 #define VSM_EXCEPTION(__exc_class, __msg, ...) \
170 throw __exc_class(__exc_class::Va_args_overload(), "%s" __msg, "", ## __VA_ARGS__)
178 #define VSM_PARAM_EXCEPTION(__exc_class, __param, __msg, ...) \
180 throw __exc_class(__exc_class::Va_args_overload(), __param, "%s" __msg, "", ## __VA_ARGS__)
190 #define VSM_SYS_EXCEPTION(__msg, ...) do { \
191 std::string sys_msg = ugcs::vsm::Log::Get_system_error(); \
192 VSM_EXCEPTION(ugcs::vsm::System_exception, __msg ": %s", ## __VA_ARGS__, sys_msg.c_str()); \
200 #define VSM_DEFINE_EXCEPTION(__exc_class, ...) \
201 struct __exc_class ## _dummy_struct {}; \
202 typedef ugcs::vsm::Param_exception<__exc_class ## _dummy_struct, ## __VA_ARGS__> __exc_class
208 #define VSM_DEFINE_DERIVED_EXCEPTION(__base_class, __exc_class) \
210 struct __exc_class ## _dummy_struct {}; \
212 typedef ugcs::vsm::Derived_exception<__base_class, __exc_class ## _dummy_struct> __exc_class
Exception class with one parameter.
Definition: exception.h:86
Derived_exception(Args &&...args)
Forwarding constructor.
Definition: exception.h:137
Exception()
Default constructor should not be used often.
Definition: exception.h:44
void Create_msg(const char *msg, va_list args)
Create message string (data member "msg") from format parameters.
Common preprocessor definitions.
#define __FORMAT(type, fmt_idx, arg_idx)
Specify that a function has format arguments (like printf or scanf).
Definition: defs.h:24
Param_exception(Va_args_overload, const char *msg,...)
Different constructors for optionally taking the parameter value and formatted message.
Definition: exception.h:95
TParam param
User-defined parameter.
Definition: exception.h:89
std::string msg
Exception message.
Definition: exception.h:72
virtual const char * what() const noexceptoverride
Get readable exception description.
Definition: exception.h:65
VSM_DEFINE_EXCEPTION(Debug_assert_exception)
Exception to throw when debugging assertion fires.
Dummy structure to explicitly indicate the constructor overload for variable arguments (i...
Definition: exception.h:38
Dummy structure to explicitly indicate the constructor overload for va_list type argument.
Definition: exception.h:30
Helper class for defining derived exceptions.
Definition: exception.h:133
Base class for all VSM exceptions.
Definition: exception.h:22