Skip to content

Commit

Permalink
downloader: Avoid noise in download error
Browse files Browse the repository at this point in the history
Do't annotate to avoid unnecessary information in the error.
  • Loading branch information
Menno Smits committed Sep 26, 2016
1 parent f376b9d commit f1f40de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion downloader/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (dl *Download) run(req Request) {
// disableSSLHostnameVerification behavior here.
filename, err := dl.download(req)
if err != nil {
err = errors.Annotatef(err, "cannot download %q", req.URL)
err = errors.Trace(err)
} else {
logger.Infof("download complete (%q)", req.URL)
err = verifyDownload(filename, req)
Expand Down
4 changes: 2 additions & 2 deletions downloader/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *DownloadSuite) TestDownloadError(c *gc.C) {
)
filename, err := d.Wait()
c.Assert(filename, gc.Equals, "")
c.Assert(err, gc.ErrorMatches, `cannot download ".*": bad http response: 404 Not Found`)
c.Assert(err, gc.ErrorMatches, `bad http response: 404 Not Found`)
checkDirEmpty(c, tmp)
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (s *DownloadSuite) TestAbort(c *gc.C) {
)
filename, err := dl.Wait()
c.Check(filename, gc.Equals, "")
c.Check(err, gc.ErrorMatches, ".+ download aborted")
c.Check(err, gc.ErrorMatches, "download aborted")
checkDirEmpty(c, tmp)
}

Expand Down
8 changes: 4 additions & 4 deletions worker/uniter/charm/bundles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func (s *BundlesDirSuite) TestGet(c *gc.C) {

// Try to get the charm when the content doesn't match.
_, err = d.Read(&fakeBundleInfo{apiCharm, nil, "..."}, nil)
c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to download charm "cs:quantal/dummy-1" from API server: `)+`expected sha256 "...", got ".*"`)
c.Check(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to download charm "cs:quantal/dummy-1" from API server: `)+`expected sha256 "...", got ".*"`)

// Try to get a charm whose bundle doesn't exist.
otherURL := corecharm.MustParseURL("cs:quantal/spam-1")
_, err = d.Read(&fakeBundleInfo{apiCharm, otherURL, ""}, nil)
c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to download charm "cs:quantal/spam-1" from API server: `)+`.* not found`)
c.Check(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to download charm "cs:quantal/spam-1" from API server: `)+`.* not found`)

// Get a charm whose bundle exists and whose content matches.
ch, err := d.Read(apiCharm, nil)
Expand All @@ -135,8 +135,8 @@ func (s *BundlesDirSuite) TestGet(c *gc.C) {
close(abort)

ch, err = d.Read(apiCharm, abort)
c.Assert(ch, gc.IsNil)
c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to download charm "cs:quantal/dummy-1" from API server: download aborted`))
c.Check(ch, gc.IsNil)
c.Check(err, gc.ErrorMatches, regexp.QuoteMeta(`failed to download charm "cs:quantal/dummy-1" from API server: download aborted`))
}

func assertCharm(c *gc.C, bun charm.Bundle, sch *state.Charm) {
Expand Down

0 comments on commit f1f40de

Please sign in to comment.