about summary refs log tree commit diff stats
path: root/ranger/gui/widgets/browsercolumn.py
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2017-01-20 16:09:19 +0100
committernfnty <git@nfnty.se>2017-01-21 23:09:24 +0100
commit1687e0f41f172cef6923f75f4c6f1038f19671dc (patch)
tree6b9fcb40ed3637cf13a8a9be9975504aadb5e90b /ranger/gui/widgets/browsercolumn.py
parente53369588ee44a9fc4ec75228dc041448aa778d4 (diff)
downloadranger-1687e0f41f172cef6923f75f4c6f1038f19671dc.tar.gz
linting: pylint: Enable `broad-except`, Improve logging
Handle exceptions explicitly to prevent unexpected errors from causing
problems.

Improve exception and notification logging.
Diffstat (limited to 'ranger/gui/widgets/browsercolumn.py')
-rw-r--r--ranger/gui/widgets/browsercolumn.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 6f890dab..b0435785 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -5,6 +5,7 @@
 
 from __future__ import (absolute_import, division, print_function)
 
+import curses
 import stat
 from time import time
 from os.path import splitext
@@ -76,13 +77,14 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
                 elif event.pressed(3):
                     try:
                         clicked_file = self.target.files[index]
+                    except IndexError:
+                        pass
+                    else:
                         if clicked_file.is_directory:
                             self.fm.enter_dir(clicked_file.path)
                         elif self.level == 0:
                             self.fm.thisdir.move_to_obj(clicked_file)
                             self.fm.execute_file(clicked_file)
-                    except Exception:
-                        pass
 
         else:
             if self.level > 0 and not direction:
@@ -102,7 +104,7 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
         """
         try:
             self.win.move(line, 0)
-        except Exception:
+        except curses.error:
             return
         for entry in commands:
             text, attr = entry
@@ -363,11 +365,10 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
             predisplay_left += textstring
             space -= textstringlen
 
+            assert space >= 0, "Error: there is not enough space to write the text. " \
+                "I have computed spaces wrong."
             if space > 0:
                 predisplay_left.append([' ' * space, []])
-            elif space < 0:
-                raise Exception("Error: there is not enough space to write "
-                                "the text. I have computed spaces wrong.")
 
             # Computing display data. Now we compute the display_data list
             # ready to display in curses. It is a list of lists [string, attr]