{"record":{"id":"e77ff748a0a2a42c","repo":"geektutu/7days-golang","slug":"h-error-e77ff7","errorCode":null,"errorMessage":"h.Error","messagePattern":"h\\.Error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gee-rpc/day7-registry/client.go","lineNumber":151,"sourceCode":"\t\t}\n\t}\n}\n\nfunc (client *Client) receive() {\n\tvar err error\n\tfor err == nil {\n\t\tvar h codec.Header\n\t\tif err = client.cc.ReadHeader(&h); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tcall := client.removeCall(h.Seq)\n\t\tswitch {\n\t\tcase call == nil:\n\t\t\t// it usually means that Write partially failed\n\t\t\t// and call was already removed.\n\t\t\terr = client.cc.ReadBody(nil)\n\t\tcase h.Error != \"\":\n\t\t\tcall.Error = fmt.Errorf(h.Error)\n\t\t\terr = client.cc.ReadBody(nil)\n\t\t\tcall.done()\n\t\tdefault:\n\t\t\terr = client.cc.ReadBody(call.Reply)\n\t\t\tif err != nil {\n\t\t\t\tcall.Error = errors.New(\"reading body \" + err.Error())\n\t\t\t}\n\t\t\tcall.done()\n\t\t}\n\t}\n\t// error occurs, so terminateCalls pending calls\n\tclient.terminateCalls(err)\n}\n\n// Go invokes the function asynchronously.\n// It returns the Call structure representing the invocation.\nfunc (client *Client) Go(serviceMethod string, args, reply interface{}, done chan *Call) *Call {\n\tif done == nil {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-rpc/day7-registry/client.go#L133-L169","documentation":"Same mechanism as error 81 in day7-registry: when receive() reads a response whose header Error field is non-empty, the server reported a failure and the client converts h.Error into call.Error. The registry day adds heart-beat and registry features but the error path is unchanged.","triggerScenarios":"Server handler for the requested service/method returned an error; method not found; server failed to decode args or encode reply; call observed in the receive goroutine.","commonSituations":"Method name mismatch between client Call and server registration; wrong arg/reply types causing gob decode errors server-side; server panics converted to error responses.","solutions":["Read the actual message in call.Error from Call() and fix the server-side cause.","Confirm the service method name string matches the registered service exactly.","Verify args and reply types are gob-compatible and identical on both sides."],"exampleFix":"// before\nclient.Call(\"WrongSvc.Div\", args, reply)\n// after\nclient.Call(\"Arith.Div\", args, reply)","handlingStrategy":"try-catch","validationCode":"// Ensure server registered the service before dialing:\n// var _ = gee.Register(new(Arith))","typeGuard":null,"tryCatchPattern":"err := client.Call(\"Arith.Div\", args, reply)\nvar rpcErr error\nif err != nil {\n    log.Printf(\"call %s failed: %v\", \"Arith.Div\", err) // contains server h.Error\n    rpcErr = err\n}","preventionTips":["Share method-name constants between client and server packages.","Surface the full server error text to logs for diagnosis.","Keep request/reply structs in a shared package to avoid gob mismatches.","Handle expected domain errors (e.g. division by zero) explicitly in the client."],"tags":["rpc","server-error","remote-call"],"backgroundTag":"rpc-server-returned-error","analyzedSha":"cf3644382101dc13e7fd92e8f5c66cabc51bcd3b","analyzedAt":"2026-09-03T18:31:24.087Z","contentChangedAt":"2026-09-03T18:31:24.087Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}