@@ -1180,21 +1180,26 @@ static void LStat(const FunctionCallbackInfo<Value>& args){
11801180CHECK_NOT_NULL (*path);
11811181
11821182bool use_bigint = args[1 ]->IsTrue ();
1183- FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1184- if ( req_wrap_async != nullptr ){ // lstat(path, use_bigint, req)
1183+ if (!args[ 2 ]-> IsUndefined ()){ // lstat(path, use_bigint, req)
1184+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
11851185FS_ASYNC_TRACE_BEGIN1 (
11861186 UV_FS_LSTAT, req_wrap_async, " path" , TRACE_STR_COPY (*path))
11871187AsyncCall (env, req_wrap_async, args, " lstat" , UTF8, AfterStat,
11881188 uv_fs_lstat, *path);
1189- } else {// lstat(path, use_bigint, undefined, ctx )
1190- CHECK_EQ (argc, 4 );
1191- FSReqWrapSync req_wrap_sync;
1189+ } else {// lstat(path, use_bigint, undefined, throw_if_no_entry )
1190+ bool do_not_throw_if_no_entry = args[ 3 ]-> IsFalse ( );
1191+ FSReqWrapSync req_wrap_sync ( " lstat " , *path) ;
11921192FS_SYNC_TRACE_BEGIN (lstat);
1193- int err = SyncCall (env, args[3 ], &req_wrap_sync, " lstat" , uv_fs_lstat,
1194- *path);
1193+ int result;
1194+ if (do_not_throw_if_no_entry){
1195+ result = SyncCallAndThrowIf (
1196+ is_uv_error_except_no_entry, env, &req_wrap_sync, uv_fs_lstat, *path);
1197+ } else {
1198+ result = SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_lstat, *path);
1199+ }
11951200FS_SYNC_TRACE_END (lstat);
1196- if (err != 0 ){
1197- return ;// error info is in ctx
1201+ if (is_uv_error (result) ){
1202+ return ;
11981203 }
11991204
12001205 Local<Value> arr = FillGlobalStatsArray (binding_data, use_bigint,
@@ -1215,19 +1220,23 @@ static void FStat(const FunctionCallbackInfo<Value>& args){
12151220int fd = args[0 ].As <Int32>()->Value ();
12161221
12171222bool use_bigint = args[1 ]->IsTrue ();
1218- FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1219- if ( req_wrap_async != nullptr ){ // fstat(fd, use_bigint, req)
1223+ if (!args[ 2 ]-> IsUndefined ()){ // fstat(fd, use_bigint, req)
1224+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
12201225FS_ASYNC_TRACE_BEGIN0 (UV_FS_FSTAT, req_wrap_async)
12211226AsyncCall (env, req_wrap_async, args, " fstat" , UTF8, AfterStat,
12221227 uv_fs_fstat, fd);
1223- } else {// fstat(fd, use_bigint, undefined, ctx)
1224- CHECK_EQ (argc, 4 );
1225- FSReqWrapSync req_wrap_sync;
1228+ } else {// fstat(fd, use_bigint, undefined, do_not_throw_error)
1229+ bool do_not_throw_error = args[2 ]->IsTrue ();
1230+ const auto should_throw = [do_not_throw_error](int result){
1231+ return is_uv_error (result) && !do_not_throw_error;
1232+ };
1233+ FSReqWrapSync req_wrap_sync (" fstat" );
12261234FS_SYNC_TRACE_BEGIN (fstat);
1227- int err = SyncCall (env, args[3 ], &req_wrap_sync, " fstat" , uv_fs_fstat, fd);
1235+ int err =
1236+ SyncCallAndThrowIf (should_throw, env, &req_wrap_sync, uv_fs_fstat, fd);
12281237FS_SYNC_TRACE_END (fstat);
1229- if (err != 0 ){
1230- return ;// error info is in ctx
1238+ if (is_uv_error ( err) ){
1239+ return ;
12311240 }
12321241
12331242 Local<Value> arr = FillGlobalStatsArray (binding_data, use_bigint,
0 commit comments