From: Cheng Zhao Date: Fri, 23 Oct 2015 06:36:36 +0000 (+0800) Subject: Pass real Error object in error event X-Git-Tag: v0.34.1~1^2~7 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=95fe4beda83318949c51e0100d46f221ab2b265e;p=electron.git Pass real Error object in error event --- diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index 250aa3e4..d8407f60 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -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() { diff --git a/docs/api/auto-updater.md b/docs/api/auto-updater.md index 9734f592..ea731cd8 100644 --- a/docs/api/auto-updater.md +++ b/docs/api/auto-updater.md @@ -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.