add onError with three params and move to atom-auto-updater

This commit is contained in:
Shelley Vohr 2017-07-26 17:33:32 -07:00
parent 1cfd20f861
commit 8cf00fece6
4 changed files with 20 additions and 65 deletions

View file

@ -57,6 +57,24 @@ void AutoUpdater::OnError(const std::string& message) {
message);
}
void AutoUpdater::OnError(const std::string& message, const int code, const std::string& domain) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
auto errorObject = error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked();
// add two new params for better error handling
errorObject->Set(mate::StringToV8(isolate(), "code"), v8::Integer::New(isolate(), code));
errorObject->Set(mate::StringToV8(isolate(), "domain"), mate::StringToV8(isolate(), domain));
mate::EmitEvent(
isolate(),
GetWrapper(),
"error",
errorObject,
message);
}
void AutoUpdater::OnCheckingForUpdate() {
Emit("checking-for-update");
}