From 33faf321b0fad0504aeb3394015a1b566fc29319 Mon Sep 17 00:00:00 2001 From: liyuke Date: Wed, 19 Mar 2025 17:05:22 +0800 Subject: [PATCH] truncateSync Signed-off-by: liyuke --- .../kits/js/src/mod_fs/properties/ani/truncate_ani.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/truncate_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/truncate_ani.cpp index f2231a37..6176d45e 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/truncate_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/truncate_ani.cpp @@ -15,6 +15,7 @@ #include "truncate_ani.h" +#include "error_handler.h" #include "file_utils.h" #include "filemgmt_libhilog.h" #include "truncate_core.h" @@ -30,18 +31,22 @@ void TruncateAni::TruncateSync(ani_env *env, [[maybe_unused]] ani_class clazz, a auto [succ, fileinfo] = TypeConverter::ToFileInfo(env, file); if (!succ) { HILOGE("Invalid fd/path"); + ErrorHandler::Throw(env, EINVAL); return; } auto [succLen, len] = TypeConverter::ToOptionalInt64(env, length); if (!succLen) { HILOGE("Invalid truncate length"); + ErrorHandler::Throw(env, EINVAL); return; } auto ret = TruncateCore::DoTruncate(fileinfo, len); if (!ret.IsSuccess()) { HILOGE("Truncate failed"); + const auto &err = ret.GetError(); + ErrorHandler::Throw(env, err); return; } } -- Gitee