2020-03-25 18:07:36 +00:00
|
|
|
#ifndef CREATURELIB_CORE_HPP
|
|
|
|
#define CREATURELIB_CORE_HPP
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <exception>
|
|
|
|
#include <string>
|
|
|
|
#define export extern "C"
|
|
|
|
|
2020-04-14 13:43:30 +00:00
|
|
|
#define CreatureLibException 1;
|
|
|
|
|
2020-03-25 18:07:36 +00:00
|
|
|
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); \
|
2020-04-14 13:43:30 +00:00
|
|
|
return CreatureLibException; \
|
2020-03-25 18:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CREATURELIB_CORE_HPP
|