f
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user