Uncaught exception logs written to disk

Issue:https://gitcode.com/openharmony/arkcompiler_runtime_core/issues/9463?ref=&did=3744723#tid-3744723

Signed-off-by: rentangyu <rentangyu@huawei.com>
This commit is contained in:
rentangyu
2026-03-04 15:40:58 +08:00
parent 686e166f47
commit 1a2d738f60
@@ -189,6 +189,22 @@ void ETSEnvironment::RegisterUncaughtExceptionHandler(const ETSUncaughtException
{
TAG_LOGD(AAFwkTag::ETSRUNTIME, "RegisterUncaughtExceptionHandler called");
uncaughtExceptionInfo_ = handle;
auto callback = [handle] (ani_error aniError) {
std::string errorMsg = ETSEnvironment::GetInstance()->GetErrorProperty(aniError, "message");
std::string errorName = ETSEnvironment::GetInstance()->GetErrorProperty(aniError, "name");
std::string errorStack = ETSEnvironment::GetInstance()->GetErrorProperty(aniError, "stack");
std::string summary = "Error name:" + errorName + "\n";
summary += "Error message:" + errorMsg + "\n";
summary += "Stacktrace:\n";
if (errorStack.find(BACKTRACE) != std::string::npos) {
summary += ETSEnvironment::GetInstance()->GetBuildId(errorStack);
} else {
summary += errorStack;
}
ETSErrorObject errorObj{errorName, errorMsg, errorStack};
handle.uncaughtTask(summary, errorObj);
};
ark::ets::ETSAni::RegisterETSUncaughtExceptionHandler(callback);
}
bool ETSEnvironment::LoadSymbolCreateVM(void *handle, ETSRuntimeAPI &apis)