autoresearch iter 2: compare error sentinels with errors.Is

Five sites used == against sentinels (redis.Nil, ingest.ErrForbidden,
errs.ErrDatabaseUninitialized). The neighbouring not-found checks already
went through errors.Is helpers, so a wrapped error would silently downgrade
a 403 to a 400 and a 500 to a 400.
This commit is contained in:
ryan
2026-08-29 07:58:59 +08:00
parent edf0c0e934
commit 37ad58699d
3 changed files with 8 additions and 5 deletions
@@ -11,6 +11,7 @@ import (
"Wavelet/plugins/domain/upload/models"
"Wavelet/plugins/domain/upload/repository"
"Wavelet/plugins/domain/upload/shared"
"errors"
"net/http"
"strconv"
@@ -233,7 +234,7 @@ func DeleteMyFile(c *gin.Context) {
response.AbortNotFound(c, shared.ErrFileRecordNotFound)
return
}
if err == ingest.ErrForbidden {
if errors.Is(err, ingest.ErrForbidden) {
response.AbortForbidden(c, shared.ErrOperationForbidden)
return
}
@@ -287,7 +288,7 @@ func UpdateMyFile(c *gin.Context) {
response.AbortNotFound(c, shared.ErrFileRecordNotFound)
return
}
if err == ingest.ErrForbidden {
if errors.Is(err, ingest.ErrForbidden) {
response.AbortForbidden(c, shared.ErrOperationForbidden)
return
}