Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: logdog/common/storage/archive/storage.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: logdog/common/storage/archive/storage.go
diff --git a/logdog/common/storage/archive/storage.go b/logdog/common/storage/archive/storage.go
index deeea3854ff5b35a19da80cff05d9ec20b5cb7e3..f2f55b78c01d7711ea889a7b9d676124554fd820 100644
--- a/logdog/common/storage/archive/storage.go
+++ b/logdog/common/storage/archive/storage.go
@@ -116,7 +116,7 @@ func (s *storageImpl) Get(req storage.GetRequest, cb storage.GetCallback) error
return storage.ErrDoesNotExist
default:
- return errors.Annotate(err).Reason("failed to read log stream").Err()
+ return errors.Annotate(err, "failed to read log stream").Err()
}
}
@@ -138,7 +138,7 @@ func (s *storageImpl) getLogEntriesIter(st *getStrategy, cb storage.GetCallback)
storageReader, err := s.Client.NewReader(s.Stream, int64(offset), length)
if err != nil {
log.WithError(err).Errorf(s, "Failed to create stream Reader.")
- return errors.Annotate(err).Reason("failed to create stream Reader").Err()
+ return errors.Annotate(err, "failed to create stream Reader").Err()
}
defer func() {
if tmpErr := storageReader.Close(); tmpErr != nil {
@@ -163,7 +163,7 @@ func (s *storageImpl) getLogEntriesIter(st *getStrategy, cb storage.GetCallback)
sz, r, err := rio.ReadFrame()
if err != nil {
- return errors.Annotate(err).Reason("failed to read frame").Err()
+ return errors.Annotate(err, "failed to read frame").Err()
}
buf.Reset()
@@ -176,11 +176,11 @@ func (s *storageImpl) getLogEntriesIter(st *getStrategy, cb storage.GetCallback)
"frameOffset": offset,
"frameSize": sz,
}.Errorf(s, "Failed to read frame data.")
- return errors.Annotate(err).Reason("failed to read frame data").Err()
+ return errors.Annotate(err, "failed to read frame data").Err()
case amt != sz:
// If we didn't buffer the complete frame, we hit a premature EOF.
- return errors.Annotate(io.EOF).Reason("incomplete frame read").Err()
+ return errors.Annotate(io.EOF, "incomplete frame read").Err()
}
// If we read from offset 0, the first frame will be the log stream's
@@ -200,7 +200,7 @@ func (s *storageImpl) getLogEntriesIter(st *getStrategy, cb storage.GetCallback)
"frameOffset": offset,
"frameSize": sz,
}.Errorf(s, "Failed to get log entry index.")
- return errors.Annotate(err).Reason("failed to get log entry index").Err()
+ return errors.Annotate(err, "failed to get log entry index").Err()
case idx < st.startIndex:
// Skip this entry, as it's before the first requested entry.
@@ -328,7 +328,7 @@ func loadIndex(c context.Context, client gs.Client, path gs.Path, cache caching.
r, err := client.NewReader(path, 0, -1)
if err != nil {
log.WithError(err).Errorf(c, "Failed to create index Reader.")
- return nil, errors.Annotate(err).Reason("failed to create index Reader").Err()
+ return nil, errors.Annotate(err, "failed to create index Reader").Err()
}
defer func() {
if err := r.Close(); err != nil {
@@ -338,14 +338,14 @@ func loadIndex(c context.Context, client gs.Client, path gs.Path, cache caching.
if indexData, err = ioutil.ReadAll(r); err != nil {
log.WithError(err).Errorf(c, "Failed to read index.")
- return nil, errors.Annotate(err).Reason("failed to read index").Err()
+ return nil, errors.Annotate(err, "failed to read index").Err()
}
}
index := logpb.LogIndex{}
if err := proto.Unmarshal(indexData, &index); err != nil {
log.WithError(err).Errorf(c, "Failed to unmarshal index.")
- return nil, errors.Annotate(err).Reason("failed to unmarshal index").Err()
+ return nil, errors.Annotate(err, "failed to unmarshal index").Err()
}
// If the index is valid, but wasn't cached previously, then cache it.
« no previous file with comments | « logdog/common/storage/archive/logdog_archive_test/main.go ('k') | logdog/common/storage/bigtable/logdog_bigtable_test/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698