Skip to content

Commit

Permalink
fix: add missing stacktrace
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 22, 2025
1 parent 991acad commit f8ba3c7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/legacy/api/APIHelp.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ inline void LOG_WRONG_ARGS_COUNT(std::string const& func = "") {
#define CATCH(LOG) \
catch (const Exception& e) { \
ll::error_utils::printException(e, lse::LegacyScriptEngine::getInstance().getSelf().getLogger()); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger("Stacktrace: {0}", e.stacktrace()); \
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
return Local<Value>(); \
} \
Expand Down Expand Up @@ -99,6 +100,7 @@ inline void LOG_WRONG_ARGS_COUNT(std::string const& func = "") {
#define CATCH_C(LOG) \
catch (const Exception& e) { \
ll::error_utils::printException(e, lse::LegacyScriptEngine::getInstance().getSelf().getLogger()); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger("Stacktrace: {0}", e.stacktrace()); \
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
return nullptr; \
} \
Expand All @@ -112,6 +114,7 @@ inline void LOG_WRONG_ARGS_COUNT(std::string const& func = "") {
#define CATCH_S(LOG) \
catch (const Exception& e) { \
ll::error_utils::printException(e, lse::LegacyScriptEngine::getInstance().getSelf().getLogger()); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger("Stacktrace: {0}", e.stacktrace()); \
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
return; \
} \
Expand All @@ -125,6 +128,7 @@ inline void LOG_WRONG_ARGS_COUNT(std::string const& func = "") {
#define CATCH_WITHOUT_RETURN(LOG) \
catch (const Exception& e) { \
ll::error_utils::printException(e, lse::LegacyScriptEngine::getInstance().getSelf().getLogger()); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger("Stacktrace: {0}", e.stacktrace()); \
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
} \
catch (...) { \
Expand All @@ -136,14 +140,23 @@ inline void LOG_WRONG_ARGS_COUNT(std::string const& func = "") {
#define CATCH_IN_CALLBACK(callback) \
catch (const Exception& e) { \
ll::error_utils::printException(e, lse::LegacyScriptEngine::getInstance().getSelf().getLogger()); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger("Stacktrace: {0}", e.stacktrace()); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger().error( \
std::string("In callback for ") + callback \
); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger().error( \
"In Plugin: " + getEngineOwnData()->pluginName \
); \
} \
catch (...) { \
ll::error_utils::printCurrentException(lse::LegacyScriptEngine::getInstance().getSelf().getLogger()); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger().error( \
std::string("In callback for ") + callback \
); \
lse::LegacyScriptEngine::getInstance().getSelf().getLogger().error( \
"In Plugin: " + getEngineOwnData()->pluginName \
); \
}

#else

// 新的宏定义, 把异常抛入脚本层处理
Expand Down

0 comments on commit f8ba3c7

Please sign in to comment.