Update error reporting middleware

This commit is contained in:
Dane Everitt
2020-12-15 21:08:00 -08:00
parent 3a26a5d39d
commit 0ecc166dcd
9 changed files with 100 additions and 114 deletions

View File

@@ -37,7 +37,7 @@ func getServerArchive(c *gin.Context) {
token := tokens.TransferPayload{}
if err := tokens.ParseToken([]byte(auth[1]), &token); err != nil {
TrackedError(err).Abort(c)
NewTrackedError(err).Abort(c)
return
}
@@ -53,7 +53,7 @@ func getServerArchive(c *gin.Context) {
st, err := s.Archiver.Stat()
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
TrackedServerError(err, s).SetMessage("failed to stat archive").Abort(c)
NewServerError(err, s).SetMessage("failed to stat archive").Abort(c)
return
}
@@ -63,13 +63,13 @@ func getServerArchive(c *gin.Context) {
checksum, err := s.Archiver.Checksum()
if err != nil {
TrackedServerError(err, s).SetMessage("failed to calculate checksum").Abort(c)
NewServerError(err, s).SetMessage("failed to calculate checksum").Abort(c)
return
}
file, err := os.Open(s.Archiver.Path())
if err != nil {
tserr := TrackedServerError(err, s)
tserr := NewServerError(err, s)
if !os.IsNotExist(err) {
tserr.SetMessage("failed to open archive for reading")
} else {