fix: update deprecated v8 api usage

This commit is contained in:
deepak1556 2019-01-21 21:57:11 +05:30
parent f09cb56f19
commit 92cfc4a62d
10 changed files with 117 additions and 94 deletions

View file

@ -29,7 +29,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestAsyncAsarJob> job,
if (args->GetNext(&value)) { if (args->GetNext(&value)) {
V8ValueConverter converter; V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
request_options.reset(converter.FromV8Value(value, context)); request_options = converter.FromV8Value(value, context);
} }
if (request_options) { if (request_options) {

View file

@ -40,7 +40,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestBufferJob> job,
if (args->GetNext(&value)) { if (args->GetNext(&value)) {
V8ValueConverter converter; V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
request_options.reset(converter.FromV8Value(value, context)); request_options = converter.FromV8Value(value, context);
} }
if (request_options) { if (request_options) {

View file

@ -29,7 +29,7 @@ void BeforeStartInUI(base::WeakPtr<URLRequestStringJob> job,
if (args->GetNext(&value)) { if (args->GetNext(&value)) {
V8ValueConverter converter; V8ValueConverter converter;
v8::Local<v8::Context> context = args->isolate()->GetCurrentContext(); v8::Local<v8::Context> context = args->isolate()->GetCurrentContext();
request_options.reset(converter.FromV8Value(value, context)); request_options = converter.FromV8Value(value, context);
} }
if (request_options) { if (request_options) {

View file

@ -198,16 +198,16 @@ bool Converter<net::HttpResponseHeaders*>::FromV8(
auto context = isolate->GetCurrentContext(); auto context = isolate->GetCurrentContext();
auto headers = v8::Local<v8::Object>::Cast(val); auto headers = v8::Local<v8::Object>::Cast(val);
auto keys = headers->GetOwnPropertyNames(); auto keys = headers->GetOwnPropertyNames(context).ToLocalChecked();
for (uint32_t i = 0; i < keys->Length(); i++) { for (uint32_t i = 0; i < keys->Length(); i++) {
v8::Local<v8::String> keyVal; v8::Local<v8::Value> keyVal;
if (!keys->Get(i)->ToString(context).ToLocal(&keyVal)) { if (!keys->Get(context, i).ToLocal(&keyVal)) {
return false; return false;
} }
std::string key; std::string key;
mate::ConvertFromV8(isolate, keyVal, &key); mate::ConvertFromV8(isolate, keyVal, &key);
auto localVal = headers->Get(keyVal); auto localVal = headers->Get(context, keyVal).ToLocalChecked();
if (localVal->IsArray()) { if (localVal->IsArray()) {
auto values = v8::Local<v8::Array>::Cast(localVal); auto values = v8::Local<v8::Array>::Cast(localVal);
for (uint32_t j = 0; j < values->Length(); j++) { for (uint32_t j = 0; j < values->Length(); j++) {

View file

@ -146,7 +146,7 @@ v8::Local<v8::Value> V8ValueConverter::ToV8Value(
return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value)); return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value));
} }
base::Value* V8ValueConverter::FromV8Value( std::unique_ptr<base::Value> V8ValueConverter::FromV8Value(
v8::Local<v8::Value> val, v8::Local<v8::Value> val,
v8::Local<v8::Context> context) const { v8::Local<v8::Context> context) const {
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
@ -180,7 +180,8 @@ v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
case base::Value::Type::STRING: { case base::Value::Type::STRING: {
std::string val = value->GetString(); std::string val = value->GetString();
return v8::String::NewFromUtf8(isolate, val.c_str(), return v8::String::NewFromUtf8(isolate, val.c_str(),
v8::String::kNormalString, val.length()); v8::NewStringType::kNormal, val.length())
.ToLocalChecked();
} }
case base::Value::Type::LIST: case base::Value::Type::LIST:
@ -288,38 +289,38 @@ v8::Local<v8::Value> V8ValueConverter::ToArrayBuffer(
return v8::Uint8Array::New(array_buffer, 0, length); return v8::Uint8Array::New(array_buffer, 0, length);
} }
base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state, std::unique_ptr<base::Value> V8ValueConverter::FromV8ValueImpl(
v8::Local<v8::Value> val, FromV8ValueState* state,
v8::Isolate* isolate) const { v8::Local<v8::Value> val,
v8::Isolate* isolate) const {
FromV8ValueState::Level state_level(state); FromV8ValueState::Level state_level(state);
if (state->HasReachedMaxRecursionDepth()) if (state->HasReachedMaxRecursionDepth())
return nullptr; return nullptr;
if (val->IsExternal()) if (val->IsExternal())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
if (val->IsNull()) if (val->IsNull())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
auto context = isolate->GetCurrentContext(); auto context = isolate->GetCurrentContext();
if (val->IsBoolean()) if (val->IsBoolean())
return new base::Value(val->ToBoolean(context).ToLocalChecked()->Value()); return std::make_unique<base::Value>(val->ToBoolean(isolate)->Value());
if (val->IsInt32()) if (val->IsInt32())
return new base::Value(val->ToInt32(context).ToLocalChecked()->Value()); return std::make_unique<base::Value>(val.As<v8::Int32>()->Value());
if (val->IsNumber()) { if (val->IsNumber()) {
double val_as_double = val->ToNumber(context).ToLocalChecked()->Value(); double val_as_double = val.As<v8::Number>()->Value();
if (!std::isfinite(val_as_double)) if (!std::isfinite(val_as_double))
return nullptr; return nullptr;
return new base::Value(val_as_double); return std::make_unique<base::Value>(val_as_double);
} }
if (val->IsString()) { if (val->IsString()) {
v8::String::Utf8Value utf8(isolate, v8::String::Utf8Value utf8(isolate, val);
val->ToString(context).ToLocalChecked()); return std::make_unique<base::Value>(std::string(*utf8, utf8.length()));
return new base::Value(std::string(*utf8, utf8.length()));
} }
if (val->IsUndefined()) if (val->IsUndefined())
@ -329,15 +330,16 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
if (val->IsDate()) { if (val->IsDate()) {
v8::Date* date = v8::Date::Cast(*val); v8::Date* date = v8::Date::Cast(*val);
v8::Local<v8::Value> toISOString = v8::Local<v8::Value> toISOString =
date->Get(v8::String::NewFromUtf8(isolate, "toISOString")); date->Get(v8::String::NewFromUtf8(isolate, "toISOString",
v8::NewStringType::kNormal)
.ToLocalChecked());
if (toISOString->IsFunction()) { if (toISOString->IsFunction()) {
v8::Local<v8::Value> result = toISOString.As<v8::Function>() v8::Local<v8::Value> result = toISOString.As<v8::Function>()
->Call(context, val, 0, nullptr) ->Call(context, val, 0, nullptr)
.ToLocalChecked(); .ToLocalChecked();
if (!result.IsEmpty()) { if (!result.IsEmpty()) {
v8::String::Utf8Value utf8(isolate, v8::String::Utf8Value utf8(isolate, result);
result->ToString(context).ToLocalChecked()); return std::make_unique<base::Value>(std::string(*utf8, utf8.length()));
return new base::Value(std::string(*utf8, utf8.length()));
} }
} }
} }
@ -345,10 +347,8 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
if (val->IsRegExp()) { if (val->IsRegExp()) {
if (!reg_exp_allowed_) if (!reg_exp_allowed_)
// JSON.stringify converts to an object. // JSON.stringify converts to an object.
return FromV8Object(val->ToObject(context).ToLocalChecked(), state, return FromV8Object(val.As<v8::Object>(), state, isolate);
isolate); return std::make_unique<base::Value>(*v8::String::Utf8Value(isolate, val));
return new base::Value(*v8::String::Utf8Value(
isolate, val->ToString(context).ToLocalChecked()));
} }
// v8::Value doesn't have a ToArray() method for some reason. // v8::Value doesn't have a ToArray() method for some reason.
@ -359,8 +359,7 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
if (!function_allowed_) if (!function_allowed_)
// JSON.stringify refuses to convert function(){}. // JSON.stringify refuses to convert function(){}.
return nullptr; return nullptr;
return FromV8Object(val->ToObject(context).ToLocalChecked(), state, return FromV8Object(val.As<v8::Object>(), state, isolate);
isolate);
} }
if (node::Buffer::HasInstance(val)) { if (node::Buffer::HasInstance(val)) {
@ -368,20 +367,20 @@ base::Value* V8ValueConverter::FromV8ValueImpl(FromV8ValueState* state,
} }
if (val->IsObject()) { if (val->IsObject()) {
return FromV8Object(val->ToObject(context).ToLocalChecked(), state, return FromV8Object(val.As<v8::Object>(), state, isolate);
isolate);
} }
LOG(ERROR) << "Unexpected v8 value type encountered."; LOG(ERROR) << "Unexpected v8 value type encountered.";
return nullptr; return nullptr;
} }
base::Value* V8ValueConverter::FromV8Array(v8::Local<v8::Array> val, std::unique_ptr<base::Value> V8ValueConverter::FromV8Array(
FromV8ValueState* state, v8::Local<v8::Array> val,
v8::Isolate* isolate) const { FromV8ValueState* state,
v8::Isolate* isolate) const {
ScopedUniquenessGuard uniqueness_guard(state, val); ScopedUniquenessGuard uniqueness_guard(state, val);
if (!uniqueness_guard.is_valid()) if (!uniqueness_guard.is_valid())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
std::unique_ptr<v8::Context::Scope> scope; std::unique_ptr<v8::Context::Scope> scope;
// If val was created in a different context than our current one, change to // If val was created in a different context than our current one, change to
@ -390,45 +389,54 @@ base::Value* V8ValueConverter::FromV8Array(v8::Local<v8::Array> val,
val->CreationContext() != isolate->GetCurrentContext()) val->CreationContext() != isolate->GetCurrentContext())
scope.reset(new v8::Context::Scope(val->CreationContext())); scope.reset(new v8::Context::Scope(val->CreationContext()));
auto* result = new base::ListValue(); std::unique_ptr<base::ListValue> result(new base::ListValue());
// Only fields with integer keys are carried over to the ListValue. // Only fields with integer keys are carried over to the ListValue.
for (uint32_t i = 0; i < val->Length(); ++i) { for (uint32_t i = 0; i < val->Length(); ++i) {
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
v8::Local<v8::Value> child_v8 = val->Get(i); v8::Local<v8::Value> child_v8;
if (try_catch.HasCaught()) { v8::MaybeLocal<v8::Value> maybe_child =
val->Get(isolate->GetCurrentContext(), i);
if (try_catch.HasCaught() || !maybe_child.ToLocal(&child_v8)) {
LOG(ERROR) << "Getter for index " << i << " threw an exception."; LOG(ERROR) << "Getter for index " << i << " threw an exception.";
child_v8 = v8::Null(isolate); child_v8 = v8::Null(isolate);
} }
if (!val->HasRealIndexedProperty(i)) if (!val->HasRealIndexedProperty(isolate->GetCurrentContext(), i)
.FromMaybe(false)) {
result->Append(std::make_unique<base::Value>());
continue; continue;
}
base::Value* child = FromV8ValueImpl(state, child_v8, isolate); std::unique_ptr<base::Value> child =
FromV8ValueImpl(state, child_v8, isolate);
if (child) if (child)
result->Append(std::unique_ptr<base::Value>(child)); result->Append(std::move(child));
else else
// JSON.stringify puts null in places where values don't serialize, for // JSON.stringify puts null in places where values don't serialize, for
// example undefined and functions. Emulate that behavior. // example undefined and functions. Emulate that behavior.
result->Append(std::make_unique<base::Value>()); result->Append(std::make_unique<base::Value>());
} }
return result; return std::move(result);
} }
base::Value* V8ValueConverter::FromNodeBuffer(v8::Local<v8::Value> value, std::unique_ptr<base::Value> V8ValueConverter::FromNodeBuffer(
FromV8ValueState* state, v8::Local<v8::Value> value,
v8::Isolate* isolate) const { FromV8ValueState* state,
return new base::Value(std::vector<char>( v8::Isolate* isolate) const {
std::vector<char> buffer(
node::Buffer::Data(value), node::Buffer::Data(value),
node::Buffer::Data(value) + node::Buffer::Length(value))); node::Buffer::Data(value) + node::Buffer::Length(value));
return std::make_unique<base::Value>(std::move(buffer));
} }
base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val, std::unique_ptr<base::Value> V8ValueConverter::FromV8Object(
FromV8ValueState* state, v8::Local<v8::Object> val,
v8::Isolate* isolate) const { FromV8ValueState* state,
v8::Isolate* isolate) const {
ScopedUniquenessGuard uniqueness_guard(state, val); ScopedUniquenessGuard uniqueness_guard(state, val);
if (!uniqueness_guard.is_valid()) if (!uniqueness_guard.is_valid())
return std::make_unique<base::Value>().release(); return std::make_unique<base::Value>();
std::unique_ptr<v8::Context::Scope> scope; std::unique_ptr<v8::Context::Scope> scope;
// If val was created in a different context than our current one, change to // If val was created in a different context than our current one, change to
@ -438,10 +446,15 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
scope.reset(new v8::Context::Scope(val->CreationContext())); scope.reset(new v8::Context::Scope(val->CreationContext()));
auto result = std::make_unique<base::DictionaryValue>(); auto result = std::make_unique<base::DictionaryValue>();
v8::Local<v8::Array> property_names(val->GetOwnPropertyNames()); v8::Local<v8::Array> property_names;
if (!val->GetOwnPropertyNames(isolate->GetCurrentContext())
.ToLocal(&property_names)) {
return std::move(result);
}
for (uint32_t i = 0; i < property_names->Length(); ++i) { for (uint32_t i = 0; i < property_names->Length(); ++i) {
v8::Local<v8::Value> key(property_names->Get(i)); v8::Local<v8::Value> key =
property_names->Get(isolate->GetCurrentContext(), i).ToLocalChecked();
// Extend this test to cover more types as necessary and if sensible. // Extend this test to cover more types as necessary and if sensible.
if (!key->IsString() && !key->IsNumber()) { if (!key->IsString() && !key->IsNumber()) {
@ -451,21 +464,21 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
continue; continue;
} }
v8::String::Utf8Value name_utf8( v8::String::Utf8Value name_utf8(isolate, key);
isolate, key->ToString(isolate->GetCurrentContext()).ToLocalChecked());
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
v8::Local<v8::Value> child_v8 = val->Get(key); v8::Local<v8::Value> child_v8;
v8::MaybeLocal<v8::Value> maybe_child =
if (try_catch.HasCaught()) { val->Get(isolate->GetCurrentContext(), key);
if (try_catch.HasCaught() || !maybe_child.ToLocal(&child_v8)) {
LOG(ERROR) << "Getter for property " << *name_utf8 LOG(ERROR) << "Getter for property " << *name_utf8
<< " threw an exception."; << " threw an exception.";
child_v8 = v8::Null(isolate); child_v8 = v8::Null(isolate);
} }
std::unique_ptr<base::Value> child( std::unique_ptr<base::Value> child =
FromV8ValueImpl(state, child_v8, isolate)); FromV8ValueImpl(state, child_v8, isolate);
if (!child.get()) if (!child)
// JSON.stringify skips properties whose values don't serialize, for // JSON.stringify skips properties whose values don't serialize, for
// example undefined and functions. Emulate that behavior. // example undefined and functions. Emulate that behavior.
continue; continue;
@ -497,7 +510,7 @@ base::Value* V8ValueConverter::FromV8Object(v8::Local<v8::Object> val,
std::move(child)); std::move(child));
} }
return result.release(); return std::move(result);
} }
} // namespace atom } // namespace atom

View file

@ -5,6 +5,8 @@
#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_ #ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_ #define ATOM_COMMON_NATIVE_MATE_CONVERTERS_V8_VALUE_CONVERTER_H_
#include <memory>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
@ -26,8 +28,9 @@ class V8ValueConverter {
void SetStripNullFromObjects(bool val); void SetStripNullFromObjects(bool val);
v8::Local<v8::Value> ToV8Value(const base::Value* value, v8::Local<v8::Value> ToV8Value(const base::Value* value,
v8::Local<v8::Context> context) const; v8::Local<v8::Context> context) const;
base::Value* FromV8Value(v8::Local<v8::Value> value, std::unique_ptr<base::Value> FromV8Value(
v8::Local<v8::Context> context) const; v8::Local<v8::Value> value,
v8::Local<v8::Context> context) const;
private: private:
class FromV8ValueState; class FromV8ValueState;
@ -43,18 +46,18 @@ class V8ValueConverter {
v8::Local<v8::Value> ToArrayBuffer(v8::Isolate* isolate, v8::Local<v8::Value> ToArrayBuffer(v8::Isolate* isolate,
const base::Value* value) const; const base::Value* value) const;
base::Value* FromV8ValueImpl(FromV8ValueState* state, std::unique_ptr<base::Value> FromV8ValueImpl(FromV8ValueState* state,
v8::Local<v8::Value> value, v8::Local<v8::Value> value,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;
base::Value* FromV8Array(v8::Local<v8::Array> array, std::unique_ptr<base::Value> FromV8Array(v8::Local<v8::Array> array,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;
base::Value* FromNodeBuffer(v8::Local<v8::Value> value, std::unique_ptr<base::Value> FromNodeBuffer(v8::Local<v8::Value> value,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;
base::Value* FromV8Object(v8::Local<v8::Object> object, std::unique_ptr<base::Value> FromV8Object(v8::Local<v8::Object> object,
FromV8ValueState* state, FromV8ValueState* state,
v8::Isolate* isolate) const; v8::Isolate* isolate) const;
// If true, we will convert RegExp JavaScript objects to string. // If true, we will convert RegExp JavaScript objects to string.
bool reg_exp_allowed_ = false; bool reg_exp_allowed_ = false;

View file

@ -30,7 +30,10 @@ v8::Maybe<bool> Promise::RejectWithErrorMessage(const std::string& string) {
v8::Local<v8::Context>::New(isolate(), GetContext())); v8::Local<v8::Context>::New(isolate(), GetContext()));
v8::Local<v8::String> error_message = v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate(), string.c_str()); v8::String::NewFromUtf8(isolate(), string.c_str(),
v8::NewStringType::kNormal,
static_cast<int>(string.size()))
.ToLocalChecked();
v8::Local<v8::Value> error = v8::Exception::Error(error_message); v8::Local<v8::Value> error = v8::Exception::Error(error_message);
return Reject(error); return Reject(error);
} }

View file

@ -140,13 +140,16 @@ bool Converter<double>::FromV8(Isolate* isolate,
} }
Local<Value> Converter<const char*>::ToV8(Isolate* isolate, const char* val) { Local<Value> Converter<const char*>::ToV8(Isolate* isolate, const char* val) {
return v8::String::NewFromUtf8(isolate, val); return v8::String::NewFromUtf8(isolate, val, v8::NewStringType::kNormal)
.ToLocalChecked();
} }
Local<Value> Converter<base::StringPiece>::ToV8(Isolate* isolate, Local<Value> Converter<base::StringPiece>::ToV8(Isolate* isolate,
const base::StringPiece& val) { const base::StringPiece& val) {
return v8::String::NewFromUtf8(isolate, val.data(), v8::String::kNormalString, return v8::String::NewFromUtf8(isolate, val.data(),
static_cast<uint32_t>(val.length())); v8::NewStringType::kNormal,
static_cast<uint32_t>(val.length()))
.ToLocalChecked();
} }
Local<Value> Converter<std::string>::ToV8(Isolate* isolate, Local<Value> Converter<std::string>::ToV8(Isolate* isolate,
@ -255,8 +258,9 @@ bool Converter<Local<Value>>::FromV8(Isolate* isolate,
v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate, v8::Local<v8::String> StringToSymbol(v8::Isolate* isolate,
const base::StringPiece& val) { const base::StringPiece& val) {
return v8::String::NewFromUtf8(isolate, val.data(), return v8::String::NewFromUtf8(isolate, val.data(),
v8::String::kInternalizedString, v8::NewStringType::kInternalized,
static_cast<uint32_t>(val.length())); static_cast<uint32_t>(val.length()))
.ToLocalChecked();
} }
} // namespace mate } // namespace mate

View file

@ -277,7 +277,8 @@ struct Converter<std::map<std::string, T>> {
v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> dict = val->ToObject(context).ToLocalChecked(); v8::Local<v8::Object> dict = val->ToObject(context).ToLocalChecked();
v8::Local<v8::Array> keys = dict->GetOwnPropertyNames(); v8::Local<v8::Array> keys =
dict->GetOwnPropertyNames(context).ToLocalChecked();
for (uint32_t i = 0; i < keys->Length(); ++i) { for (uint32_t i = 0; i < keys->Length(); ++i) {
v8::Local<v8::Value> key = keys->Get(i); v8::Local<v8::Value> key = keys->Get(i);
T value; T value;

View file

@ -6,17 +6,13 @@
namespace mate { namespace mate {
Promise::Promise() Promise::Promise() : isolate_(NULL) {}
: isolate_(NULL) {
}
Promise::Promise(v8::Isolate* isolate) Promise::Promise(v8::Isolate* isolate) : isolate_(isolate) {
: isolate_(isolate) {
resolver_ = v8::Promise::Resolver::New(isolate); resolver_ = v8::Promise::Resolver::New(isolate);
} }
Promise::~Promise() { Promise::~Promise() {}
}
Promise Promise::Create(v8::Isolate* isolate) { Promise Promise::Create(v8::Isolate* isolate) {
return Promise(isolate); return Promise(isolate);
@ -28,7 +24,10 @@ Promise Promise::Create() {
void Promise::RejectWithErrorMessage(const std::string& string) { void Promise::RejectWithErrorMessage(const std::string& string) {
v8::Local<v8::String> error_message = v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate(), string.c_str()); v8::String::NewFromUtf8(isolate(), string.c_str(),
v8::NewStringType::kNormal,
static_cast<int>(string.size()))
.ToLocalChecked();
v8::Local<v8::Value> error = v8::Exception::Error(error_message); v8::Local<v8::Value> error = v8::Exception::Error(error_message);
resolver_->Reject(mate::ConvertToV8(isolate(), error)); resolver_->Reject(mate::ConvertToV8(isolate(), error));
} }
@ -38,7 +37,7 @@ v8::Local<v8::Object> Promise::GetHandle() const {
} }
v8::Local<v8::Value> Converter<Promise>::ToV8(v8::Isolate* isolate, v8::Local<v8::Value> Converter<Promise>::ToV8(v8::Isolate* isolate,
Promise val) { Promise val) {
return val.GetHandle(); return val.GetHandle();
} }