aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/asset
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-07-21 11:51:35 +0200
committerTaras Madan <tarasmadan@google.com>2023-07-24 09:12:13 +0000
commita36fe24b8383f6cd9b3519cd3eabdb9675d8992d (patch)
tree3fef9a57760ccc4013289acd60e94e083db466e6 /pkg/asset
parent7549a7e1b57831cf6b08ce4700fc6e53417919f9 (diff)
all: use errors.As instead of .(type)
Diffstat (limited to 'pkg/asset')
-rw-r--r--pkg/asset/storage.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/asset/storage.go b/pkg/asset/storage.go
index 1debdaa4a..8bec1cca8 100644
--- a/pkg/asset/storage.go
+++ b/pkg/asset/storage.go
@@ -123,7 +123,8 @@ func (storage *Storage) uploadFileStream(reader io.Reader, assetType dashapi.Ass
compressor = typeDescr.customCompressor
}
res, err := compressor(req, storage.backend.upload)
- if existsErr, ok := err.(*FileExistsError); ok {
+ var existsErr *FileExistsError
+ if errors.As(err, &existsErr) {
storage.tracer.Log("asset %s already exists", path)
if extra == nil || !extra.SkipIfExists {
return "", err
@@ -137,7 +138,8 @@ func (storage *Storage) uploadFileStream(reader io.Reader, assetType dashapi.Ass
if err != nil {
more := ""
closeErr := res.writer.Close()
- if exiterr, ok := closeErr.(*exec.ExitError); ok {
+ var exiterr *exec.ExitError
+ if errors.As(closeErr, &exiterr) {
more = fmt.Sprintf(", process state '%s'", exiterr.ProcessState)
}
return "", fmt.Errorf("failed to redirect byte stream: copied %d bytes, error %w%s",