summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-04-25 16:00:52 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-04-25 16:00:52 +0100
commit8185ac21732bcc784b678da5954ab3cf16078fa8 (patch)
tree412c651f2aac7395312617b2fd5c81d42098cc41
parentff7327e84f75e14363ba2790b54ceed257a5f25e (diff)
downloadmorph-8185ac21732bcc784b678da5954ab3cf16078fa8.tar.gz
Add morphlib.Error and make local repo cache exceptions be based on it
This way, cliapp will automatically print an error message, rather than a stack trace.
-rw-r--r--morphlib/__init__.py8
-rw-r--r--morphlib/localrepocache.py5
2 files changed, 11 insertions, 2 deletions
diff --git a/morphlib/__init__.py b/morphlib/__init__.py
index d110296d..121c9431 100644
--- a/morphlib/__init__.py
+++ b/morphlib/__init__.py
@@ -17,6 +17,14 @@
'''Baserock library.'''
+import cliapp
+
+
+class Error(cliapp.AppException):
+
+ '''Base for all morph exceptions that cause user-visible messages.'''
+
+
import artifact
import artifactresolver
import bins
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py
index 5e04b187..b8dfea88 100644
--- a/morphlib/localrepocache.py
+++ b/morphlib/localrepocache.py
@@ -34,7 +34,7 @@ urlparse.uses_fragment.extend(gitscheme)
-class NoRemote(Exception):
+class NoRemote(morphlib.Error):
def __init__(self, reponame, errors):
self.reponame = reponame
@@ -44,13 +44,14 @@ class NoRemote(Exception):
return '\n\t'.join(['Cannot find remote git repository: %s' %
self.reponame] + self.errors)
-class NotCached(Exception):
+class NotCached(morphlib.Error):
def __init__(self, reponame):
self.reponame = reponame
def __str__(self): # pragma: no cover
return 'Repository %s is not cached yet' % self.reponame
+
class LocalRepoCache(object):
'''Manage locally cached git repositories.