|
@@ -32,13 +32,26 @@ void AutoUpdater::OnError(const std::string& message) {
|
|
|
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
|
|
v8::HandleScope handle_scope(isolate);
|
|
|
v8::Local<v8::Object> wrapper;
|
|
|
+
|
|
|
+ // We do not use gin::EmitEvent here because we do not want to
|
|
|
+ // put this in its own CallbackScope and delegate to Node.js'
|
|
|
+ // specialized handling for Error objects.
|
|
|
if (GetWrapper(isolate).ToLocal(&wrapper)) {
|
|
|
auto error = v8::Exception::Error(gin::StringToV8(isolate, message));
|
|
|
- gin_helper::EmitEvent(
|
|
|
- isolate, wrapper, "error",
|
|
|
- error->ToObject(isolate->GetCurrentContext()).ToLocalChecked(),
|
|
|
- // Message is also emitted to keep compatibility with old code.
|
|
|
- message);
|
|
|
+ std::vector<v8::Local<v8::Value>> args = {
|
|
|
+ gin::StringToV8(isolate, "error"),
|
|
|
+ gin::ConvertToV8(
|
|
|
+ isolate,
|
|
|
+ error->ToObject(isolate->GetCurrentContext()).ToLocalChecked()),
|
|
|
+ gin::StringToV8(isolate, message),
|
|
|
+ };
|
|
|
+
|
|
|
+ gin_helper::MicrotasksScope microtasks_scope(
|
|
|
+ isolate, wrapper->GetCreationContextChecked()->GetMicrotaskQueue(),
|
|
|
+ true);
|
|
|
+
|
|
|
+ node::MakeCallback(isolate, wrapper, "emit", args.size(), args.data(),
|
|
|
+ {0, 0});
|
|
|
}
|
|
|
}
|
|
|
|