diff --git a/src/permission/permission.cc b/src/permission/permission.cc index c156133e64a13d..f92dd7e03ff1e7 100644 --- a/src/permission/permission.cc +++ b/src/permission/permission.cc @@ -136,22 +136,23 @@ void Permission::ThrowAccessDenied(Environment* env, const std::string_view& res) { Local err = ERR_ACCESS_DENIED(env->isolate()); CHECK(err->IsObject()); - err.As() - ->Set(env->context(), - env->permission_string(), - v8::String::NewFromUtf8(env->isolate(), - PermissionToString(perm), - v8::NewStringType::kNormal) - .ToLocalChecked()) - .FromMaybe(false); - err.As() - ->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() + ->Set(env->context(), + env->permission_string(), + v8::String::NewFromUtf8(env->isolate(), + PermissionToString(perm), + v8::NewStringType::kNormal) + .ToLocalChecked()) + .IsNothing() || + err.As() + ->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); }