From 9be80b248385b527231eb0622b8f631b475dc743 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sat, 28 Nov 2015 21:32:37 +0530 Subject: [PATCH] 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. --- plinth/package.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plinth/package.py b/plinth/package.py index 821df66cb..01c8984d3 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -165,11 +165,11 @@ class Transaction(object): def _assert_success(self, results): """Check that the most recent operation was a success.""" - # XXX: Untested code if results and results.get_error_code() is not None: error = results.get_error_code() 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 raise PackageException(error_string, error_details) @@ -263,9 +263,10 @@ def _should_show_install_view(request, package_names): _('Installed and configured packages successfully')) return False else: - messages.error(request, _('Error installing packages: {details}') - .format(details=getattr(exception, 'error_string', - str(exception)))) + error_string = getattr(exception, 'error_string', str(exception)) + error_details = getattr(exception, 'error_details', '') + messages.error(request, _('Error installing packages: {string} {details}') + .format(string=error_string, details=error_details)) return True