Skip to content

Commit

Permalink
src: fix useless call in permission.cc
Browse files Browse the repository at this point in the history
FromMaybe() has no side effects and the return value is ignored.
Instead, if Set() fails, then another exception is pending, so
return early.
  • Loading branch information
tniessen committed Feb 25, 2023
1 parent 347215e commit 0e95c5a
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/permission/permission.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,23 @@ void Permission::ThrowAccessDenied(Environment* env,
const std::string_view& res) {
Local<Value> err = ERR_ACCESS_DENIED(env->isolate());
CHECK(err->IsObject());
err.As<Object>()
->Set(env->context(),
env->permission_string(),
v8::String::NewFromUtf8(env->isolate(),
PermissionToString(perm),
v8::NewStringType::kNormal)
.ToLocalChecked())
.FromMaybe(false);
err.As<Object>()
->Set(env->context(),
env->resource_string(),
v8::String::NewFromUtf8(env->isolate(),
std::string(res).c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked())
.FromMaybe(false);
if (err.As<Object>()
->Set(env->context(),
env->permission_string(),
v8::String::NewFromUtf8(env->isolate(),
PermissionToString(perm),
v8::NewStringType::kNormal)
.ToLocalChecked())
.IsNothing() ||
err.As<Object>()
->Set(env->context(),
env->resource_string(),
v8::String::NewFromUtf8(env->isolate(),
std::string(res).c_str(),
v8::NewStringType::kNormal)
.ToLocalChecked())
.IsNothing())
return;
env->isolate()->ThrowException(err);
}

Expand Down

0 comments on commit 0e95c5a

Please sign in to comment.