diff --git a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/IWorkIntegrationErrorCodeConstants.java b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/IWorkIntegrationErrorCodeConstants.java index 9faf4e1c..faf0c9ab 100644 --- a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/IWorkIntegrationErrorCodeConstants.java +++ b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/IWorkIntegrationErrorCodeConstants.java @@ -10,13 +10,13 @@ public interface IWorkIntegrationErrorCodeConstants { ErrorCode IWORK_BASE_URL_MISSING = new ErrorCode(1_010_200_001, "iWork 集成未配置网关地址"); ErrorCode IWORK_CONFIGURATION_INVALID = new ErrorCode(1_010_200_002, "iWork 集成缺少必填配置(appId/userId/workflowId)或配置无效"); - ErrorCode IWORK_REGISTER_FAILED = new ErrorCode(1_010_200_003, "iWork 注册授权失败"); - ErrorCode IWORK_APPLY_TOKEN_FAILED = new ErrorCode(1_010_200_004, "iWork 令牌申请失败"); - ErrorCode IWORK_REMOTE_REQUEST_FAILED = new ErrorCode(1_010_200_005, "iWork 接口请求失败"); + ErrorCode IWORK_REGISTER_FAILED = new ErrorCode(1_010_200_003, "iWork 注册授权失败:{}"); + ErrorCode IWORK_APPLY_TOKEN_FAILED = new ErrorCode(1_010_200_004, "iWork 令牌申请失败:{}"); + ErrorCode IWORK_REMOTE_REQUEST_FAILED = new ErrorCode(1_010_200_005, "iWork 接口请求失败:{}"); ErrorCode IWORK_USER_IDENTIFIER_MISSING = new ErrorCode(1_010_200_006, "缺少用户识别信息,无法调用 iWork 接口"); ErrorCode IWORK_OPERATOR_USER_MISSING = new ErrorCode(1_010_200_007, "缺少 iWork 操作人用户编号"); ErrorCode IWORK_WORKFLOW_ID_MISSING = new ErrorCode(1_010_200_008, "缺少 iWork 流程模板编号"); ErrorCode IWORK_ORG_IDENTIFIER_MISSING = new ErrorCode(1_010_200_009, "iWork 人力组织接口缺少认证标识"); - ErrorCode IWORK_ORG_REMOTE_FAILED = new ErrorCode(1_010_200_010, "iWork 人力组织接口请求失败{}"); + ErrorCode IWORK_ORG_REMOTE_FAILED = new ErrorCode(1_010_200_010, "iWork 人力组织接口请求失败:{}"); ErrorCode IWORK_SEAL_REQUIRED_FIELD_MISSING = new ErrorCode(1_010_200_011, "缺少用印必填字段:{}"); } diff --git a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java index 4e319c07..3c6885d3 100644 --- a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java +++ b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java @@ -850,15 +850,26 @@ public class IWorkIntegrationServiceImpl implements IWorkIntegrationService { } private ServiceException buildRemoteException(ErrorCode errorCode, int statusCode, String responseBody) { - StringBuilder message = new StringBuilder(errorCode.getMsg()); + String detail = buildRemoteErrorDetail(statusCode, responseBody); + if (!StringUtils.hasText(detail)) { + detail = "未知错误"; + } + return ServiceExceptionUtil.exception(errorCode, detail); + } + + private String buildRemoteErrorDetail(int statusCode, String responseBody) { + StringBuilder detail = new StringBuilder(); if (statusCode > 0) { - message.append("(HTTP ").append(statusCode).append(")"); + detail.append("HTTP ").append(statusCode); } String reason = extractReadableReason(responseBody); if (StringUtils.hasText(reason)) { - message.append(":").append(reason); + if (detail.length() > 0) { + detail.append(","); + } + detail.append(reason); } - return ServiceExceptionUtil.exception0(errorCode.getCode(), message.toString()); + return detail.toString(); } private String extractReadableReason(String responseBody) {