This commit is contained in:
Mrx
2026-01-31 12:15:42 +08:00
parent a6f858dbd3
commit ff86cb6fb9
13 changed files with 47 additions and 10 deletions

View File

@@ -31,12 +31,15 @@ func NewShujubaoError(code, message string) *ShujubaoError {
// 数据宝全系统错误码与描述映射Code -> Desc
var systemErrorCodeDesc = map[string]string{
"10000": "成功",
"10001": "参数传入有误",
"10001": "查空",
"10002": "查询失败",
"10003": "系统处理异常",
"10004": "系统处理超时",
"10005": "服务异常",
"10006": "查无",
"10017": "查询失败",
"10018": "参数错误",
"10019": "系统异常",
"10020": "同一参数请求次数超限",
"99999": "其他错误",
"999": "接口处理异常",

View File

@@ -20,6 +20,7 @@ import (
var (
ErrDatasource = errors.New("数据源异常")
ErrSystem = errors.New("系统异常")
ErrQueryEmpty = errors.New("查询为空")
)
// ShujubaoResp 数据宝 API 通用响应(按实际文档调整)
@@ -253,7 +254,10 @@ func (s *ShujubaoService) CallAPI(ctx context.Context, apiPath string, params ma
}
code := shujubaoResp.Code
if code != "10000" && code != "10006" {
if code == "10001" || code == "10006" {
return nil, ErrQueryEmpty
}
if code != "10000" {
shujubaoErr := NewShujubaoErrorFromCode(code, shujubaoResp.Message)
if s.logger != nil {
s.logger.LogError(requestID, transactionID, apiPath, shujubaoErr, params)