diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2017-12-05 12:14:57 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2017-12-12 08:10:21 +0100 |
commit | 8a85df22ec433d8ec78c9b47faaa9b2ff4f2ad5d (patch) | |
tree | f4d72d7195fad8a6eb52cbd0a4b51c06c1e33d4d /buildstream/_ostree.py | |
parent | 9c9a9acc45a3ddb6609174c9df5a9cec54cbd54c (diff) | |
download | buildstream-8a85df22ec433d8ec78c9b47faaa9b2ff4f2ad5d.tar.gz |
_ostree.py: Avoid raising GLib.Error from configure_remote()
This call can fail (if we pass an invalid remote name, for example) so
we should wrap the GLib.Error with OSTreeException.
In the case of GLib.Error this is especially important as GLib.Error
can't be pickled and so such exceptions disappear completely when we try
to propagate them back from multiprocessing subprocesses. See
<https://bugzilla.gnome.org/show_bug.cgi?id=791265>.
Diffstat (limited to 'buildstream/_ostree.py')
-rw-r--r-- | buildstream/_ostree.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py index 69256bb5a..5e533e2dd 100644 --- a/buildstream/_ostree.py +++ b/buildstream/_ostree.py @@ -320,12 +320,15 @@ def configure_remote(repo, remote, url, key_url=None): vd.insert_value('gpg-verify', Variant.new_boolean(False)) options = vd.end() - repo.remote_change(None, # Optional OSTree.Sysroot - OSTree.RepoRemoteChange.ADD_IF_NOT_EXISTS, - remote, # Remote name - url, # Remote url - options, # Remote options - None) # Optional Gio.Cancellable + try: + repo.remote_change(None, # Optional OSTree.Sysroot + OSTree.RepoRemoteChange.ADD_IF_NOT_EXISTS, + remote, # Remote name + url, # Remote url + options, # Remote options + None) # Optional Gio.Cancellable + except GLib.GError as e: + raise OSTreeError("Failed to configure remote '{}': {}".format(remote, e.message)) from e # Remote needs to exist before adding key if key_url is not None: |