about summary refs log tree commit diff stats
path: root/ranger/api/commands.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/api/commands.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/api/commands.py')
-rw-r--r--ranger/api/commands.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index 25353b5b..6b761de8 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -29,18 +29,14 @@ class CommandContainer(object):
         return self.commands[key]
 
     def alias(self, name, full_command):
-        try:
-            cmd = type(name, (AliasCommand, ), dict())
-            # pylint: disable=protected-access
-            cmd._based_function = name
-            cmd._function_name = name
-            cmd._object_name = name
-            cmd._line = full_command
-            # pylint: enable=protected-access
-            self.commands[name] = cmd
-
-        except Exception:
-            pass
+        cmd = type(name, (AliasCommand, ), dict())
+        # pylint: disable=protected-access
+        cmd._based_function = name
+        cmd._function_name = name
+        cmd._object_name = name
+        cmd._line = full_command
+        # pylint: enable=protected-access
+        self.commands[name] = cmd
 
     def load_commands_from_module(self, module):
         for var in vars(module).values():
@@ -392,13 +388,13 @@ class FunctionCommand(Command):
             value = arg if (equal_sign is -1) else arg[equal_sign + 1:]
             try:
                 value = int(value)
-            except Exception:
+            except ValueError:
                 if value in ('True', 'False'):
                     value = (value == 'True')
                 else:
                     try:
                         value = float(value)
-                    except Exception:
+                    except ValueError:
                         pass
 
             if equal_sign == -1: