mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-30 22:35:12 +02:00
lint: improve error handling
This commit is contained in:
parent
ef8aec77a9
commit
a81add5d96
6 changed files with 9 additions and 5 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
|
@ -27,7 +28,7 @@ type cache struct {
|
|||
func (c *cache) Get(key string) ([]byte, bool) {
|
||||
r, err := c.object(key).NewReader(ctx)
|
||||
if err != nil {
|
||||
if err != storage.ErrObjectNotExist {
|
||||
if !errors.Is(err, storage.ErrObjectNotExist) {
|
||||
log.Printf("error reading from gcs: %v", err)
|
||||
}
|
||||
return nil, false
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
|
@ -36,7 +37,8 @@ func (c *cache) Get(key string) ([]byte, bool) {
|
|||
|
||||
resp, err := c.GetObject(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok && aerr.Code() != "NoSuchKey" {
|
||||
var aerr awserr.Error
|
||||
if errors.As(err, &aerr) && aerr.Code() != "NoSuchKey" {
|
||||
log.Printf("error fetching from s3: %v", aerr)
|
||||
}
|
||||
return nil, false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue