From 1f92d12ba2f7f5550c1df0ff6a2a33f310bc7322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E4=BD=B3=E7=82=9C?= Date: Fri, 22 Aug 2025 15:50:01 +0800 Subject: [PATCH] add try catch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 石佳炜 --- frameworks/native/backup_ext/src/ext_backup.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frameworks/native/backup_ext/src/ext_backup.cpp b/frameworks/native/backup_ext/src/ext_backup.cpp index 304936753..1c2181418 100644 --- a/frameworks/native/backup_ext/src/ext_backup.cpp +++ b/frameworks/native/backup_ext/src/ext_backup.cpp @@ -104,7 +104,17 @@ string ExtBackup::GetUsrConfig() const { vector config; AppExecFwk::BundleMgrClient client; - BExcepUltils::BAssert(abilityInfo_, BError::Codes::EXT_BROKEN_FRAMEWORK, "Invalid abilityInfo_"); + try { + BExcepUltils::BAssert(abilityInfo_, BError::Codes::EXT_BROKEN_FRAMEWORK, "Invalid abilityInfo_"); + } catch (const BError &e) { + return ""; + } catch (const exception &e) { + HILOGE("%{public}s", e.what()); + return ""; + } catch (...) { + HILOGE("Unknown exception"); + return ""; + } const AppExecFwk::AbilityInfo &info = *abilityInfo_; if (!client.GetProfileFromAbility(info, "ohos.extension.backup", config)) { throw BError(BError::Codes::EXT_INVAL_ARG, "Failed to invoke the GetProfileFromAbility method."); -- Gitee