diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-04-16 15:57:58 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-04-16 16:03:23 +0100 |
commit | 6375554363c111fda70b7540c3c56a0e9cf1497b (patch) | |
tree | 46cd93eda94aa5009dc8626949e23658fb8e4962 /morphlib/cachedrepo_tests.py | |
parent | e7e90384da00a8197c5e0363a5a4005754a790eb (diff) | |
download | morph-6375554363c111fda70b7540c3c56a0e9cf1497b.tar.gz |
Stop using bare except: statements
It is almost never a good idea to catch all exceptions, and then do
nothing about them. This patch logs all caught exceptions so that the
user has some possibilty to debug what is happening.
Also, make ./check check for bare excepts and fail the test suite if it
finds anything.
Diffstat (limited to 'morphlib/cachedrepo_tests.py')
-rw-r--r-- | morphlib/cachedrepo_tests.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/morphlib/cachedrepo_tests.py b/morphlib/cachedrepo_tests.py index 9251a473..3e042b19 100644 --- a/morphlib/cachedrepo_tests.py +++ b/morphlib/cachedrepo_tests.py @@ -14,6 +14,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import logging import os import unittest @@ -42,7 +43,7 @@ class CachedRepoTests(unittest.TestCase): } try: return output[ref] - except: + except KeyError: raise cliapp.AppException('git rev-parse --verify %s' % ref) def show_tree_hash(self, absref): @@ -56,7 +57,7 @@ class CachedRepoTests(unittest.TestCase): } try: return output[absref] - except: + except KeyError: raise cliapp.AppException('git log -1 --format=format:%%T %s' % absref) @@ -67,7 +68,7 @@ class CachedRepoTests(unittest.TestCase): } try: return output['%s:%s' % (ref, filename)] - except: + except KeyError: raise cliapp.AppException( 'git cat-file blob %s:%s' % (ref, filename)) @@ -91,7 +92,7 @@ class CachedRepoTests(unittest.TestCase): } try: return output[ref] - except: + except KeyError: raise cliapp.AppException('git ls-tree --name-only %s' % (ref)) def clone_into(self, target_dir, ref): |