Many fixes for script handling.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
#include "Core.hpp"
|
||||
|
||||
std::string ExceptionHandler::_pkmnLibLastException = "";
|
||||
export const char* PkmnLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }
|
||||
std::string ExceptionHandler::_pkmnLibLastExceptionStacktrace = "Unset";
|
||||
|
||||
export const char* PkmnLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }
|
||||
export const char* PkmnLib_C_GetLastExceptionStacktrace() { return ExceptionHandler::GetLastExceptionStacktrace(); }
|
||||
@@ -10,19 +10,37 @@
|
||||
|
||||
class ExceptionHandler {
|
||||
static std::string _pkmnLibLastException;
|
||||
static std::string _pkmnLibLastExceptionStacktrace;
|
||||
|
||||
public:
|
||||
static void SetLastException(const std::exception& e) { _pkmnLibLastException = std::string(e.what()); }
|
||||
static void SetLastArbUtException(const std::string& function, const ArbUt::Exception& e, size_t depth = 6) {
|
||||
std::stringstream ss;
|
||||
ss << "[" << function << "] " << e.what();
|
||||
_pkmnLibLastException = ss.str();
|
||||
_pkmnLibLastExceptionStacktrace = e.GetStacktrace(depth, true);
|
||||
if (_pkmnLibLastExceptionStacktrace.empty())
|
||||
_pkmnLibLastExceptionStacktrace = "err";
|
||||
}
|
||||
static void SetLastException(const std::string& function, const std::exception& e) {
|
||||
std::stringstream ss;
|
||||
ss << "[" << function << "] " << e.what();
|
||||
_pkmnLibLastException = ss.str();
|
||||
_pkmnLibLastExceptionStacktrace = "Exception did not have a stacktrace.";
|
||||
}
|
||||
static const char* GetLastException() { return _pkmnLibLastException.c_str(); }
|
||||
static const char* GetLastExceptionStacktrace() { return _pkmnLibLastExceptionStacktrace.c_str(); }
|
||||
};
|
||||
|
||||
#define Try(data) \
|
||||
try { \
|
||||
data; \
|
||||
return 0; \
|
||||
} catch (const ArbUt::Exception& e) { \
|
||||
ExceptionHandler::SetLastArbUtException(__FUNCTION__, e); \
|
||||
return PkmnLibException; \
|
||||
} catch (const std::exception& e) { \
|
||||
ExceptionHandler::SetLastException(e); \
|
||||
return PkmnLibException; \
|
||||
ExceptionHandler::SetLastException(__FUNCTION__, e); \
|
||||
return PkmnLibException; \
|
||||
}
|
||||
|
||||
#define SIMPLE_GET_FUNC(type, name, returnType) \
|
||||
|
||||
Reference in New Issue
Block a user