◐ Shell
clean mode source ↗

src: make more error handling improvements · nodejs/node@90cd780

@@ -67,9 +67,9 @@ static void GetHostname(const FunctionCallbackInfo<Value>& args) {

67676868

if (r != 0) {

6969

CHECK_GE(args.Length(), 1);

70-

env->CollectUVExceptionInfo(args[args.Length() - 1], r,

71-

"uv_os_gethostname");

72-

return args.GetReturnValue().SetUndefined();

70+

USE(env->CollectUVExceptionInfo(

71+

args[args.Length() - 1], r, "uv_os_gethostname"));

72+

return;

7373

}

74747575

Local<Value> ret;

@@ -85,8 +85,9 @@ static void GetOSInformation(const FunctionCallbackInfo<Value>& args) {

85858686

if (err != 0) {

8787

CHECK_GE(args.Length(), 1);

88-

env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_os_uname");

89-

return args.GetReturnValue().SetUndefined();

88+

USE(env->CollectUVExceptionInfo(

89+

args[args.Length() - 1], err, "uv_os_uname"));

90+

return;

9091

}

91929293

// [sysname, version, release, machine]

@@ -159,8 +160,8 @@ static void GetUptime(const FunctionCallbackInfo<Value>& args) {

159160

double uptime;

160161

int err = uv_uptime(&uptime);

161162

if (err != 0) {

162-

env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_uptime");

163-

return args.GetReturnValue().SetUndefined();

163+

USE(env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_uptime"));

164+

return;

164165

}

165166166167

args.GetReturnValue().Set(uptime);

@@ -189,14 +190,13 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {

189190190191

int err = uv_interface_addresses(&interfaces, &count);

191192192-

if (err == UV_ENOSYS)

193-

return args.GetReturnValue().SetUndefined();

193+

if (err == UV_ENOSYS) return;

194194195195

if (err) {

196196

CHECK_GE(args.Length(), 1);

197-

env->CollectUVExceptionInfo(args[args.Length() - 1], errno,

198-

"uv_interface_addresses");

199-

return args.GetReturnValue().SetUndefined();

197+

USE(env->CollectUVExceptionInfo(

198+

args[args.Length() - 1], errno, "uv_interface_addresses"));

199+

return;

200200

}

201201202202

Local<Value> no_scope_id = Integer::New(isolate, -1);

@@ -267,8 +267,9 @@ static void GetHomeDirectory(const FunctionCallbackInfo<Value>& args) {

267267268268

if (err) {

269269

CHECK_GE(args.Length(), 1);

270-

env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_os_homedir");

271-

return args.GetReturnValue().SetUndefined();

270+

USE(env->CollectUVExceptionInfo(

271+

args[args.Length() - 1], err, "uv_os_homedir"));

272+

return;

272273

}

273274274275

Local<String> home;

@@ -299,9 +300,9 @@ static void GetUserInfo(const FunctionCallbackInfo<Value>& args) {

299300300301

if (const int err = uv_os_get_passwd(&pwd)) {

301302

CHECK_GE(args.Length(), 2);

302-

env->CollectUVExceptionInfo(args[args.Length() - 1], err,

303-

"uv_os_get_passwd");

304-

return args.GetReturnValue().SetUndefined();

303+

USE(env->CollectUVExceptionInfo(

304+

args[args.Length() - 1], err, "uv_os_get_passwd"));

305+

return;

305306

}

306307307308

auto free_passwd = OnScopeLeave([&] { uv_os_free_passwd(&pwd); });

@@ -371,7 +372,10 @@ static void SetPriority(const FunctionCallbackInfo<Value>& args) {

371372372373

if (err) {

373374

CHECK(args[2]->IsObject());

374-

env->CollectUVExceptionInfo(args[2], err, "uv_os_setpriority");

375+

if (env->CollectUVExceptionInfo(args[2], err, "uv_os_setpriority")

376+

.IsNothing()) {

377+

return;

378+

}

375379

}

376380377381

args.GetReturnValue().Set(err);

@@ -390,7 +394,7 @@ static void GetPriority(const FunctionCallbackInfo<Value>& args) {

390394391395

if (err) {

392396

CHECK(args[1]->IsObject());

393-

env->CollectUVExceptionInfo(args[1], err, "uv_os_getpriority");

397+

USE(env->CollectUVExceptionInfo(args[1], err, "uv_os_getpriority"));

394398

return;

395399

}

396400