buffet: Pass error from GCD if available.

This helps when e.g. the passed registration ticket is not found:

 # buffet_client RegisterDevice "ticket_id=bogus&client_secret=REDACTED&api_key=REDACTED&oauth_url=https://accounts.google.com/o/oauth2/&service_url=https://www.googleapis.com/clouddevices/v1/"
 [0212/152521:ERROR:logging.h(777)] Failed to call method: org.chromium.Buffet.Manager.RegisterDevice: object_path= /org/chromium/Buffet/Manager: org.freedesktop.DBus.Error.Failed: gcd_server/notFound:Registration ticket not found
 [0212/152521:ERROR:dbus_method_invoker.h(110)] CallMethodAndBlockWithTimeout(...): Domain=dbus, Code=org.freedesktop.DBus.Error.Failed, Message=gcd_server/notFound:Registration ticket not found
Failed to receive a response: gcd_server/notFound:Registration ticket not found

as opposed to just getting

 Device registered:

Also detect when RegisterDevice() returns an empty string and set the
error manually. This hack can be removed once RegisterDevice() has
been fixed to always set an error when failing (e.g. returning an
empty string).

BUG=brillo:19
TEST=Manual test.

Change-Id: Ia1b11c4039dd4474cd2a757634edc6fcd62c02b2
Reviewed-on: https://chromium-review.googlesource.com/249390
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
2 files changed
tree: f010a6d52b270c602f917be731b81c4fa3dc867a
  1. buffet/