This commit is contained in:
Mrx
2026-01-19 14:28:21 +08:00
parent 2d5c2120fb
commit 85bd011fd3
2 changed files with 25 additions and 0 deletions

View File

@@ -231,6 +231,28 @@ func (j *JiguangService) CallAPI(ctx context.Context, apiCode string, apiPath st
// 根据错误类型返回不同的错误
if jiguangErr.IsNoRecord() {
// 从context中获取apiCode判断是否需要抛出异常
var processorCode string
if ctxProcessorCode, ok := ctx.Value("api_code").(string); ok {
processorCode = ctxProcessorCode
}
// 定义需要在查无记录时抛出异常的处理器列表
processorsToThrowError := map[string]bool{
"QCXG9P1C": true, // QCXG9P1C 处理器在查无记录时需要抛出异常
"QCXG4D2E": true, // QCXG4D2E 处理器在查无记录时需要抛出异常
"QCXG5F3A": true, // QCXG5F3A 处理器在查无记录时需要抛出异常
}
// 如果是特定处理器,抛出异常;否则返回空数组
if processorsToThrowError[processorCode] {
// 记录错误日志
if j.logger != nil {
j.logger.LogErrorWithResponseID(requestID, transactionID, apiCode, jiguangErr, params, jiguangResp.OrderID)
}
return nil, errors.Join(ErrNotFound, jiguangErr)
}
// 查无记录时返回空数组API调用记录为成功
return []byte("[]"), nil
}