{"record":{"id":"fd01943418a538b3","repo":"egametang/ET","slug":"rpc-error-request-response-response","errorCode":null,"errorMessage":"Rpc error: {request}, response: {response}","messagePattern":"Rpc error: (.+?), response: (.+?)","errorType":"exception","errorClass":"RpcException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.login/Scripts/Hotfix/Client/Login/ClientSenderComponentSystem.cs","lineNumber":86,"sourceCode":"            self.Root().GetComponent<ProcessInnerSender>().Send(self.FiberInstanceId, a2NetClientMessage);\n        }\n\n        public static async ETTask<IResponse> Call(this ClientSenderComponent self, IRequest request, bool needException = true)\n        {\n            A2NetClient_Request a2NetClientRequest = A2NetClient_Request.Create();\n            a2NetClientRequest.MessageObject = request;\n            \n            using A2NetClient_Response a2NetClientResponse = await self.Root().GetComponent<ProcessInnerSender>().Call(self.FiberInstanceId, a2NetClientRequest) as A2NetClient_Response;\n            IResponse response = a2NetClientResponse.MessageObject;\n            \n            if (response.Error == ErrorCode.ERR_MessageTimeout)\n            {\n                throw new RpcException(response.Error, $\"Rpc error: request, 注意Actor消息超时，请注意查看是否死锁或者没有reply: {request}, response: {response}\");\n            }\n\n            if (needException && ErrorCode.IsRpcNeedThrowException(response.Error))\n            {\n                throw new RpcException(response.Error, $\"Rpc error: {request}, response: {response}\");\n            }\n            return response;\n        }\n\n    }\n}\n","sourceCodeStart":68,"sourceCodeEnd":93,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.login/Scripts/Hotfix/Client/Login/ClientSenderComponentSystem.cs#L68-L93","documentation":"Thrown as RpcException by ClientSenderComponent.Call when the RPC response has an error code that ErrorCode.IsRpcNeedThrowException considers throwable, but is NOT the timeout code. This is the general RPC failure path for server-side errors, rejections, or protocol violations that require the caller to handle via exception.","triggerScenarios":"The server responds with a non-timeout error code (e.g. authentication failure, invalid request, server internal error) and needException is true (the default). The caller gets an RpcException with the error code embedded.","commonSituations":"Authentication or authorization failure on the server. Invalid request parameters rejected by the server. Server-side exception during request handling that returns an error code. Passing needException=false to suppress the throw and inspect the error code manually.","solutions":["Read the ErrorCode value from the RpcException to determine the specific server-side failure reason.","If the error is expected (e.g. auth retry), call with needException=false and handle the error code in the response instead.","Fix the server-side handler that is returning the error code."],"exampleFix":"// before: needException defaults to true, throws on any RPC error\nIResponse resp = await self.Call(request);\n// after: suppress exception and handle error code\nIResponse resp = await self.Call(request, needException: false);\nif (resp.Error != ErrorCode.ERR_Success)\n{\n    Log.Error($\"RPC failed with code {resp.Error}\");\n    // handle gracefully\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { IResponse resp = await self.Call(request); } catch (RpcException e) { Log.Error($\"RPC error {e.Error} for {request.GetType().Name}: {e.Message}\"); /* handle specific error codes */ }","preventionTips":["For expected error codes (auth failure, rate limit), pass needException: false and handle the response.Error directly.","Log the ErrorCode from the RpcException to categorize and diagnose server-side failures.","Share ErrorCode constants between client and server to avoid mismatched error handling."],"tags":["network","rpc","error-handling","login"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}