summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-02-09 13:15:38 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-02-11 16:04:43 +0000
commit59f5d084705c90c5c8345c816f90abe14f075cd7 (patch)
treea32460d9fbbcb2aac4b24d3c45782d535bea31d8
parent99d9d30f957eb11bb20f2aab7281f22aed9dcf88 (diff)
downloadmorph-59f5d084705c90c5c8345c816f90abe14f075cd7.tar.gz
Show full error on stdout when artifact fetching fails
The error is logged in morph.log already but, this can be hard to get at if the build ran on a distbuild network.
-rw-r--r--morphlib/remoteartifactcache.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/morphlib/remoteartifactcache.py b/morphlib/remoteartifactcache.py
index 4e09ce34..499c2aab 100644
--- a/morphlib/remoteartifactcache.py
+++ b/morphlib/remoteartifactcache.py
@@ -29,29 +29,29 @@ class HeadRequest(urllib2.Request): # pragma: no cover
class GetError(cliapp.AppException):
- def __init__(self, cache, artifact):
+ def __init__(self, cache, artifact, error):
cliapp.AppException.__init__(
self, 'Failed to get the artifact %s '
- 'from the artifact cache %s' %
- (artifact.basename(), cache))
+ 'from the artifact cache %s: %s' %
+ (artifact.basename(), cache, error))
class GetArtifactMetadataError(GetError):
- def __init__(self, cache, artifact, name):
+ def __init__(self, cache, artifact, name, error):
cliapp.AppException.__init__(
self, 'Failed to get metadata %s for the artifact %s '
- 'from the artifact cache %s' %
- (name, artifact.basename(), cache))
+ 'from the artifact cache %s: %s' %
+ (name, artifact.basename(), cache, error))
class GetSourceMetadataError(GetError):
- def __init__(self, cache, source, cache_key, name):
+ def __init__(self, cache, source, cache_key, name, error):
cliapp.AppException.__init__(
self, 'Failed to get metadata %s for source %s '
- 'and cache key %s from the artifact cache %s' %
- (name, source, cache_key, cache))
+ 'and cache key %s from the artifact cache %s: %s' %
+ (name, source, cache_key, cache, error))
class RemoteArtifactCache(object):
@@ -72,23 +72,23 @@ class RemoteArtifactCache(object):
def get(self, artifact, log=logging.error):
try:
return self._get_file(artifact.basename())
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
log(str(e))
- raise GetError(self, artifact)
+ raise GetError(self, artifact, e)
def get_artifact_metadata(self, artifact, name, log=logging.error):
try:
return self._get_file(artifact.metadata_basename(name))
- except urllib2.URLError, e:
+ except urllib2.URLError as e:
log(str(e))
- raise GetArtifactMetadataError(self, artifact, name)
+ raise GetArtifactMetadataError(self, artifact, name, e)
def get_source_metadata(self, source, cachekey, name):
filename = '%s.%s' % (cachekey, name)
try:
return self._get_file(filename)
- except urllib2.URLError:
- raise GetSourceMetadataError(self, source, cachekey, name)
+ except urllib2.URLError as e:
+ raise GetSourceMetadataError(self, source, cachekey, name, e)
def _has_file(self, filename): # pragma: no cover
url = self._request_url(filename)