27 lines
1.3 KiB
C++
27 lines
1.3 KiB
C++
#ifndef CREATURELIB_CORE_HPP
|
|
#define CREATURELIB_CORE_HPP
|
|
|
|
#include <cstring>
|
|
#include <exception>
|
|
#include <string>
|
|
#define export extern "C"
|
|
|
|
class ExceptionHandler {
|
|
static std::string _lastException;
|
|
|
|
public:
|
|
static void SetLastException(const std::exception& e) { _lastException = std::string(e.what()); }
|
|
static const char* GetLastException() { return _lastException.c_str(); }
|
|
};
|
|
|
|
#define Try(data) \
|
|
try { \
|
|
data; \
|
|
return 0; \
|
|
} catch (const std::exception& e) { \
|
|
ExceptionHandler::SetLastException(e); \
|
|
return 1; \
|
|
}
|
|
|
|
#endif // CREATURELIB_CORE_HPP
|