This commit is contained in:
Mrx
2026-03-26 11:31:11 +08:00
parent 8bbd098f97
commit a73097aed3
2 changed files with 20 additions and 14 deletions

View File

@@ -319,15 +319,28 @@ func (s *ApiApplicationServiceImpl) callExternalApi(ctx context.Context, cmd *co
callContext)
if err != nil {
mappedErrorType := entities.ApiCallErrorSystem
if errors.Is(err, processors.ErrDatasource) {
return "", ErrSystem
mappedErrorType = entities.ApiCallErrorDatasource
} else if errors.Is(err, processors.ErrInvalidParam) {
return "", ErrInvalidParam
mappedErrorType = entities.ApiCallErrorInvalidParam
} else if errors.Is(err, processors.ErrNotFound) {
return "", ErrQueryEmpty
} else {
return "", ErrSystem
mappedErrorType = entities.ApiCallErrorQueryEmpty
}
s.logger.Error("调用第三方接口失败",
zap.String("transaction_id", validation.ApiCall.TransactionId),
zap.String("api_name", cmd.ApiName),
zap.String("error_type", mappedErrorType),
zap.Error(err))
if mappedErrorType == entities.ApiCallErrorInvalidParam {
return "", ErrInvalidParam
}
if mappedErrorType == entities.ApiCallErrorQueryEmpty {
return "", ErrQueryEmpty
}
return "", ErrSystem
}
return string(response), nil