Skip to content

Commit

Permalink
fix: no such object error code (#1423)
Browse files Browse the repository at this point in the history
* fix: not found error code
  • Loading branch information
BarryTong65 committed Jul 9, 2024
1 parent d939fcf commit b1060f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions modular/gater/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ func ErrNotifySwapOutWithDetail(detail string) *gfsperrors.GfSpError {
func ErrConsensusWithDetail(detail string) *gfsperrors.GfSpError {
return gfsperrors.Register(module.GateModularName, http.StatusInternalServerError, 55001, detail)
}

func ErrConsensusNotFoundWithDetail(detail string) *gfsperrors.GfSpError {
return gfsperrors.Register(module.GateModularName, http.StatusNotFound, 55002, detail)
}
6 changes: 5 additions & 1 deletion modular/gater/object_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,11 @@ func (g *GateModular) downloadObject(w http.ResponseWriter, reqCtx *RequestConte
metrics.PerfGetObjectTimeHistogram.WithLabelValues("get_object_get_object_info_time").Observe(time.Since(getObjectTime).Seconds())
if err != nil {
log.CtxErrorw(reqCtx.Context(), "failed to get object info from consensus", "error", err)
err = ErrConsensusWithDetail("failed to get object info from consensus, object_name: " + reqCtx.objectName + ", bucket_name: " + reqCtx.bucketName + ", error:" + err.Error())
if strings.Contains(err.Error(), "No such object") {
err = ErrConsensusNotFoundWithDetail("failed to get object info from consensus, the object may be deleted. object_name: " + reqCtx.objectName + ", bucket_name: " + reqCtx.bucketName + ", error:" + err.Error())
} else {
err = ErrConsensusWithDetail("failed to get object info from consensus, object_name: " + reqCtx.objectName + ", bucket_name: " + reqCtx.bucketName + ", error:" + err.Error())
}
return err
}

Expand Down

0 comments on commit b1060f1

Please sign in to comment.