Tweaks for exception handling.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-07-28 19:37:03 +02:00
parent e2e706693b
commit 13c4609cdd
5 changed files with 12 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
#include "Core.hpp"
std::string ExceptionHandler::_creatureLibLastException = "";
export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }

View File

@@ -11,15 +11,15 @@
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
class ExceptionHandler {
static std::string _lastException;
static std::string _creatureLibLastException;
public:
static void SetLastException(std::string function, const std::exception& e) {
std::stringstream ss;
ss << "[" << function << "] " << e.what();
_lastException = ss.str();
_creatureLibLastException = ss.str();
}
static const char* GetLastException() { return _lastException.c_str(); }
static const char* GetLastException() { return _creatureLibLastException.c_str(); }
};
#define Try(data) \