summaryrefslogtreecommitdiff
path: root/morphlib/remoterepocache.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-04-16 15:57:58 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-04-16 16:03:23 +0100
commit6375554363c111fda70b7540c3c56a0e9cf1497b (patch)
tree46cd93eda94aa5009dc8626949e23658fb8e4962 /morphlib/remoterepocache.py
parente7e90384da00a8197c5e0363a5a4005754a790eb (diff)
downloadmorph-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/remoterepocache.py')
-rw-r--r--morphlib/remoterepocache.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/morphlib/remoterepocache.py b/morphlib/remoterepocache.py
index 5c2017de..d6812120 100644
--- a/morphlib/remoterepocache.py
+++ b/morphlib/remoterepocache.py
@@ -16,6 +16,7 @@
import cliapp
import json
+import logging
import urllib2
import urlparse
@@ -53,14 +54,16 @@ class RemoteRepoCache(object):
repo_url = self._resolver.pull_url(repo_name)
try:
return self._resolve_ref_for_repo_url(repo_url, ref)
- except:
+ except BaseException, e:
+ logging.error('Caught exception: %s' % str(e))
raise ResolveRefError(repo_name, ref)
def cat_file(self, repo_name, ref, filename):
repo_url = self._resolver.pull_url(repo_name)
try:
return self._cat_file_for_repo_url(repo_url, ref, filename)
- except:
+ except BaseException, e:
+ logging.error('Caught exception: %s' % str(e))
raise CatFileError(repo_name, ref, filename)
def ls_tree(self, repo_name, ref):
@@ -68,7 +71,8 @@ class RemoteRepoCache(object):
try:
info = json.loads(self._ls_tree_for_repo_url(repo_url, ref))
return info['tree'].keys()
- except:
+ except BaseException, e:
+ logging.error('Caught exception: %s' % str(e))
raise LsTreeError(repo_name, ref)
def _resolve_ref_for_repo_url(self, repo_url, ref): # pragma: no cover