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 f2231a37a6b6e6e57b777668a1e59d9dc31dedfd..6176d45e123c92a84e679d4b6ccce0bc7f6fc9e3 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; } }