소스 검색

fix(api): 修复错误响应处理逻辑

- 更新了 Response 结构体的 Message 字段赋值逻辑,使用 data 中的字符串值- 优化了错误代码不存在时的处理方式,统一了错误信息的返回格式
fusu 3 달 전
부모
커밋
2014fd9a68
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      api/v1/v1.go

+ 1 - 1
api/v1/v1.go

@@ -27,7 +27,7 @@ func HandleError(ctx *gin.Context, httpCode int, err error, data interface{}) {
 	if data == nil {
 		data = map[string]string{}
 	}
-	resp := Response{Code: errorCodeMap[err], Message: err.Error(), Data: data}
+	resp := Response{Code: errorCodeMap[err], Message: data.(string), Data: data}
 	if _, ok := errorCodeMap[err]; !ok {
 		resp = Response{Code: 500, Message: data.(string)}
 	}