Skip to content

Commit

Permalink
improved error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
sfomuseumbot committed Nov 16, 2022
1 parent 3a539b2 commit 8647fc8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cachereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewCacheReader(ctx context.Context, uri string) (reader.Reader, error) {
u, err := url.Parse(uri)

if err != nil {
return nil, err
return nil, fmt.Errorf("Failed to parse URI, %w", err)
}

q := u.Query()
Expand Down Expand Up @@ -74,19 +74,19 @@ func (cr *CacheReader) Read(ctx context.Context, key string) (io.ReadSeekCloser,
}

if !cache.IsCacheMiss(err) {
return nil, err
return nil, fmt.Errorf("Failed to read from cache for %s with %T, %w", key, cr.cache, err)
}

fh, err = cr.reader.Read(ctx, key)

if err != nil {
return nil, err
return nil, fmt.Errorf("Failed to read %s from %T, %w", key, cr.reader, err)
}

fh, err = cr.cache.Set(ctx, key, fh)

if err != nil {
return nil, err
return nil, fmt.Errorf("Failed to set cache for %s with %T, %w", key, cr.cache, err)
}

// https://github.com/whosonfirst/go-cache/issues/1
Expand Down

0 comments on commit 8647fc8

Please sign in to comment.