refactor: share package registry error status classification (#39133)

Signed-off-by: silverwind <me@silverwind.io>
This commit is contained in:
silverwind authored and GitHub committed 2026-09-03 18:43:30 +00:00
1 parent 0fff5f481e
commit c285440e03
11 files changed
+22 -62

No files matched your search

+2 -10
View File
@@ -43,11 +43,7 @@ func DownloadPackageFile(ctx *context.Context) {
ctx.Req.Method,
)
if err != nil {
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, packages_model.ErrPackageFileNotExist) {
apiError(ctx, http.StatusNotFound, err)
return
}
apiError(ctx, http.StatusInternalServerError, err)
apiError(ctx, helper.PackageErrorStatus(err), err)
return
}
@@ -180,11 +176,7 @@ func DeletePackageFile(ctx *context.Context) {
return pv, pf, nil
}()
if err != nil {
if errors.Is(err, packages_model.ErrPackageNotExist) || errors.Is(err, packages_model.ErrPackageFileNotExist) {
apiError(ctx, http.StatusNotFound, err)
return
}
apiError(ctx, http.StatusInternalServerError, err)
apiError(ctx, helper.PackageErrorStatus(err), err)
return
}