Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -3,3 +3,4 @@
|
||||
std::string ExceptionHandler::_creatureLibLastException = "";
|
||||
|
||||
export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); }
|
||||
export const char* CreatureLib_C_GetLastExceptionStacktrace() { return ExceptionHandler::GetLastExceptionStacktrace(); }
|
||||
|
||||
@@ -13,20 +13,23 @@
|
||||
|
||||
class ExceptionHandler {
|
||||
static std::string _creatureLibLastException;
|
||||
static std::string _creatureLibLastExceptionStacktrace;
|
||||
|
||||
public:
|
||||
static void SetLastException(std::string function, const ArbUt::Exception& e) {
|
||||
static void SetLastArbUtException(const std::string& function, const ArbUt::Exception& e) {
|
||||
std::stringstream ss;
|
||||
ss << "[" << function << "] " << e.what() << std::endl;
|
||||
ss << e.GetStacktrace();
|
||||
_creatureLibLastException = ss.str();
|
||||
_creatureLibLastExceptionStacktrace = e.GetStacktrace();
|
||||
}
|
||||
static void SetLastException(std::string function, const std::exception& e) {
|
||||
static void SetLastException(const std::string& function, const std::exception& e) {
|
||||
std::stringstream ss;
|
||||
ss << "[" << function << "] " << e.what();
|
||||
_creatureLibLastException = ss.str();
|
||||
_creatureLibLastExceptionStacktrace = "";
|
||||
}
|
||||
static const char* GetLastException() { return _creatureLibLastException.c_str(); }
|
||||
static const char* GetLastExceptionStacktrace() { return _creatureLibLastExceptionStacktrace.c_str(); }
|
||||
};
|
||||
|
||||
#define Try(data) \
|
||||
@@ -34,7 +37,7 @@ public:
|
||||
data; \
|
||||
return 0; \
|
||||
} catch (const ArbUt::Exception& e) { \
|
||||
ExceptionHandler::SetLastException(__FUNCTION__, e); \
|
||||
ExceptionHandler::SetLastArbUtException(__FUNCTION__, e); \
|
||||
return CreatureLibException; \
|
||||
} catch (const std::exception& e) { \
|
||||
ExceptionHandler::SetLastException(__FUNCTION__, e); \
|
||||
|
||||
Reference in New Issue
Block a user