update_engine: Use helper Command::AbortWithCustomError() method
weaved now provides new variants of Command::Abort() that allow
to specify the error information as brillo::Error or binder::Status.
Command::AbortWithCustomError(brillo::Error*) also makes sure the error
code is prepended with "_", so no need to add that in OnTrackChannel().
BUG: 25875613
Change-Id: Ic9b2cb6f6ef092b85883ebb5bf5e4c936aa770f0
diff --git a/update_attempter.cc b/update_attempter.cc
index bc06502..dd7c1be 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1098,7 +1098,7 @@
brillo::Error::AddTo(error,
FROM_HERE,
brillo::errors::dbus::kDomain,
- "_set_target_error",
+ "set_target_error",
error_message);
return false;
}
diff --git a/weave_service.cc b/weave_service.cc
index 414234c..c6a67f2 100644
--- a/weave_service.cc
+++ b/weave_service.cc
@@ -101,7 +101,7 @@
void WeaveService::OnCheckForUpdates(std::unique_ptr<weaved::Command> command) {
brillo::ErrorPtr error;
if (!delegate_->OnCheckForUpdates(&error)) {
- command->Abort(error->GetCode(), error->GetMessage(), nullptr);
+ command->AbortWithCustomError(error.get(), nullptr);
return;
}
command->Complete({}, nullptr);
@@ -111,7 +111,7 @@
string channel = command->GetParameter<string>("channel");
brillo::ErrorPtr error;
if (!delegate_->OnTrackChannel(channel, &error)) {
- command->Abort(error->GetCode(), error->GetMessage(), nullptr);
+ command->AbortWithCustomError(error.get(), nullptr);
return;
}
command->Complete({}, nullptr);