Better error captures

This commit is contained in:
Dane Everitt
2020-08-27 19:57:22 -07:00
parent 68ab705aac
commit 0e474c8b24
3 changed files with 13 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/apex/log"
"github.com/pkg/errors"
"io"
"net/http"
"os"
@@ -33,17 +34,17 @@ func (s *S3Backup) Generate(included *IncludedFiles, prefix string) (*ArchiveDet
}
if _, err := a.Create(s.Path(), context.Background()); err != nil {
return nil, err
return nil, errors.WithStack(err)
}
rc, err := os.Open(s.Path())
if err != nil {
return nil, err
return nil, errors.WithStack(err)
}
defer rc.Close()
if resp, err := s.generateRemoteRequest(rc); err != nil {
return nil, err
return nil, errors.WithStack(err)
} else {
resp.Body.Close()