Pass real Error object in error event
authorCheng Zhao <zcbenz@gmail.com>
Fri, 23 Oct 2015 06:36:36 +0000 (14:36 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 23 Oct 2015 06:37:35 +0000 (14:37 +0800)
atom/browser/api/atom_api_auto_updater.cc
docs/api/auto-updater.md

index 250aa3e..d8407f6 100644 (file)
@@ -23,8 +23,15 @@ AutoUpdater::~AutoUpdater() {
   auto_updater::AutoUpdater::SetDelegate(NULL);
 }
 
-void AutoUpdater::OnError(const std::string& error) {
-  Emit("error", error);
+void AutoUpdater::OnError(const std::string& message) {
+  v8::Locker locker(isolate());
+  v8::HandleScope handle_scope(isolate());
+  auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
+  EmitCustomEvent(
+      "error",
+      error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
+      // Message is also emitted to keep compatibility with old code.
+      message);
 }
 
 void AutoUpdater::OnCheckingForUpdate() {
index 9734f59..ea731cd 100644 (file)
@@ -110,8 +110,7 @@ The `autoUpdater` object emits the following events:
 
 Returns:
 
-* `event` Event
-* `message` String
+* `error` Error
 
 Emitted when there is an error while updating.