Skip to content

Commit 9ceadf6

Browse files
committed
fix(RPC): 捕获异常时设置默认错误码
当RPC处理过程中发生异常且响应未设置错误码时,自动设置为内部服务器错误码,避免返回未定义错误状态
1 parent 5c37e6f commit 9ceadf6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

GameFrameX.Core/BaseHandler/RPC/BaseRpcComponentHandler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ async Task Work()
147147
catch (Exception e)
148148
{
149149
LogHelper.Error(e, $"InnerAction error: {RequestMessage.GetType().FullName} {RequestMessage}");
150+
if (response != null && response.ErrorCode == default)
151+
{
152+
response.ErrorCode = OperationErrorCode.InternalServerError;
153+
}
150154
}
151155

152156
if (NetWorkChannel == null || NetWorkChannel.IsClosed() || response == null)

0 commit comments

Comments
 (0)