aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-03-28 12:45:59 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-03-28 12:47:25 +0100
commit0677ff04822aff11b124d42c2d4b6a6cea66b7d3 (patch)
treefd464540f81376e27863a696d7ae69dec566bc8a
parent820a82613a6ff820bfc959bf914d488a52a679df (diff)
downloadsos-0677ff04822aff11b124d42c2d4b6a6cea66b7d3.tar.gz
[sosreport] log exception detail when waiting on user input
If we catch an exception while waiting on user input, exit with status 130 if the exception is KeyboardInterrupt, otherwise log the exception text and exit with the exception as the status. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 02d9b21c..ee33a9fa 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -1176,9 +1176,13 @@ class SoSReport(object):
msg += _("Press ENTER to continue, or CTRL-C to quit.\n")
try:
input(msg)
- except Exception as err:
+ except KeyboardInterrupt as e:
+ self.ui_log.error("Exiting on user cancel")
+ self._exit(130)
+ except Exception as e:
self.ui_log.info("")
- self._exit(err)
+ self.ui_log.error(e)
+ self._exit(e)
def _log_plugin_exception(self, plugin, method):
trace = traceback.format_exc()