mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user