@@ -1215,21 +1215,26 @@ static void LStat(const FunctionCallbackInfo<Value>& args){
12151215CHECK_NOT_NULL (*path);
12161216
12171217bool use_bigint = args[1 ]->IsTrue ();
1218- FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1219- if ( req_wrap_async != nullptr ){ // lstat(path, use_bigint, req)
1218+ if (!args[ 2 ]-> IsUndefined ()){ // lstat(path, use_bigint, req)
1219+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
12201220FS_ASYNC_TRACE_BEGIN1 (
12211221 UV_FS_LSTAT, req_wrap_async, " path" , TRACE_STR_COPY (*path))
12221222AsyncCall (env, req_wrap_async, args, " lstat" , UTF8, AfterStat,
12231223 uv_fs_lstat, *path);
1224- } else {// lstat(path, use_bigint, undefined, ctx )
1225- CHECK_EQ (argc, 4 );
1226- FSReqWrapSync req_wrap_sync;
1224+ } else {// lstat(path, use_bigint, undefined, throw_if_no_entry )
1225+ bool do_not_throw_if_no_entry = args[ 3 ]-> IsFalse ( );
1226+ FSReqWrapSync req_wrap_sync ( " lstat " , *path) ;
12271227FS_SYNC_TRACE_BEGIN (lstat);
1228- int err = SyncCall (env, args[3 ], &req_wrap_sync, " lstat" , uv_fs_lstat,
1229- *path);
1228+ int result;
1229+ if (do_not_throw_if_no_entry){
1230+ result = SyncCallAndThrowIf (
1231+ is_uv_error_except_no_entry, env, &req_wrap_sync, uv_fs_lstat, *path);
1232+ } else {
1233+ result = SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_lstat, *path);
1234+ }
12301235FS_SYNC_TRACE_END (lstat);
1231- if (err != 0 ){
1232- return ;// error info is in ctx
1236+ if (is_uv_error (result) ){
1237+ return ;
12331238 }
12341239
12351240 Local<Value> arr = FillGlobalStatsArray (binding_data, use_bigint,
@@ -1250,19 +1255,23 @@ static void FStat(const FunctionCallbackInfo<Value>& args){
12501255int fd = args[0 ].As <Int32>()->Value ();
12511256
12521257bool use_bigint = args[1 ]->IsTrue ();
1253- FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1254- if ( req_wrap_async != nullptr ){ // fstat(fd, use_bigint, req)
1258+ if (!args[ 2 ]-> IsUndefined ()){ // fstat(fd, use_bigint, req)
1259+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
12551260FS_ASYNC_TRACE_BEGIN0 (UV_FS_FSTAT, req_wrap_async)
12561261AsyncCall (env, req_wrap_async, args, " fstat" , UTF8, AfterStat,
12571262 uv_fs_fstat, fd);
1258- } else {// fstat(fd, use_bigint, undefined, ctx)
1259- CHECK_EQ (argc, 4 );
1260- FSReqWrapSync req_wrap_sync;
1263+ } else {// fstat(fd, use_bigint, undefined, do_not_throw_error)
1264+ bool do_not_throw_error = args[2 ]->IsTrue ();
1265+ const auto should_throw = [do_not_throw_error](int result){
1266+ return is_uv_error (result) && !do_not_throw_error;
1267+ };
1268+ FSReqWrapSync req_wrap_sync (" fstat" );
12611269FS_SYNC_TRACE_BEGIN (fstat);
1262- int err = SyncCall (env, args[3 ], &req_wrap_sync, " fstat" , uv_fs_fstat, fd);
1270+ int err =
1271+ SyncCallAndThrowIf (should_throw, env, &req_wrap_sync, uv_fs_fstat, fd);
12631272FS_SYNC_TRACE_END (fstat);
1264- if (err != 0 ){
1265- return ;// error info is in ctx
1273+ if (is_uv_error ( err) ){
1274+ return ;
12661275 }
12671276
12681277 Local<Value> arr = FillGlobalStatsArray (binding_data, use_bigint,
0 commit comments