diff --git a/modules/ugdk-core/include/ugdk/system/exceptions.h b/modules/ugdk-core/include/ugdk/system/exceptions.h index d13bc8d9..48afd815 100644 --- a/modules/ugdk-core/include/ugdk/system/exceptions.h +++ b/modules/ugdk-core/include/ugdk/system/exceptions.h @@ -8,7 +8,10 @@ namespace system { class BaseException { public: - BaseException(const char * fmt, ...); + template + BaseException(const std::string& fmt, Args... args) { + set_reason(fmt.c_str(), args...); + } virtual ~BaseException() throw() {} inline virtual const char * what() const throw() { @@ -17,6 +20,7 @@ class BaseException { private: std::string reason_; + void set_reason(const char* fmt, ...); }; class InvalidOperation : public BaseException { @@ -34,4 +38,4 @@ void AssertCondition(bool condition, Args... args) { } // namespace system } // namespace ugdk -#endif // UGDK_SYSTEM_EXCEPTIONS_H_ \ No newline at end of file +#endif // UGDK_SYSTEM_EXCEPTIONS_H_ diff --git a/modules/ugdk-core/src/system/exceptions.cc b/modules/ugdk-core/src/system/exceptions.cc index e21ee800..0dc4f0fc 100644 --- a/modules/ugdk-core/src/system/exceptions.cc +++ b/modules/ugdk-core/src/system/exceptions.cc @@ -28,8 +28,7 @@ namespace ugdk { namespace system { -BaseException::BaseException(const char * fmt, ...) -{ +void BaseException::set_reason(const char* fmt, ...) { va_list args; int size_buffer = 256, size_out; char * buffer;