mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
packages: Fix issue with handling some errors
I got an error when one of the sources in my sources.list is untrusted. The error code was available as 'gpg-error' and more description was available. Our untested code to handle that threw an exception in that case. This patch fixes it. I have tested with the error I got as the error was easily reproducible.
This commit is contained in:
parent
8e8f8118c4
commit
9be80b2483
@ -165,11 +165,11 @@ class Transaction(object):
|
|||||||
|
|
||||||
def _assert_success(self, results):
|
def _assert_success(self, results):
|
||||||
"""Check that the most recent operation was a success."""
|
"""Check that the most recent operation was a success."""
|
||||||
# XXX: Untested code
|
|
||||||
if results and results.get_error_code() is not None:
|
if results and results.get_error_code() is not None:
|
||||||
error = results.get_error_code()
|
error = results.get_error_code()
|
||||||
error_code = error.get_code() if error else None
|
error_code = error.get_code() if error else None
|
||||||
error_string = error_code.to_string() if error_code else None
|
error_string = packagekit.ErrorEnum.to_string(error_code) \
|
||||||
|
if error_code else None
|
||||||
error_details = error.get_details() if error else None
|
error_details = error.get_details() if error else None
|
||||||
raise PackageException(error_string, error_details)
|
raise PackageException(error_string, error_details)
|
||||||
|
|
||||||
@ -263,9 +263,10 @@ def _should_show_install_view(request, package_names):
|
|||||||
_('Installed and configured packages successfully'))
|
_('Installed and configured packages successfully'))
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
messages.error(request, _('Error installing packages: {details}')
|
error_string = getattr(exception, 'error_string', str(exception))
|
||||||
.format(details=getattr(exception, 'error_string',
|
error_details = getattr(exception, 'error_details', '')
|
||||||
str(exception))))
|
messages.error(request, _('Error installing packages: {string} {details}')
|
||||||
|
.format(string=error_string, details=error_details))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user