{"record":{"id":"b91029624dbee022","repo":"geektutu/7days-golang","slug":"err-error-b91029","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"gee-cache/day7-proto-buf/geecache/http.go","lineNumber":69,"sourceCode":"\t// /<basepath>/<groupname>/<key> required\n\tparts := strings.SplitN(r.URL.Path[len(p.basePath):], \"/\", 2)\n\tif len(parts) != 2 {\n\t\thttp.Error(w, \"bad request\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tgroupName := parts[0]\n\tkey := parts[1]\n\n\tgroup := GetGroup(groupName)\n\tif group == nil {\n\t\thttp.Error(w, \"no such group: \"+groupName, http.StatusNotFound)\n\t\treturn\n\t}\n\n\tview, err := group.Get(key)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Write the value to the response body as a proto message.\n\tbody, err := proto.Marshal(&pb.Response{Value: view.ByteSlice()})\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/octet-stream\")\n\tw.Write(body)\n}\n\n// Set updates the pool's list of peers.\nfunc (p *HTTPPool) Set(peers ...string) {\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-cache/day7-proto-buf/geecache/http.go#L51-L87","documentation":"Generic 500 handler in HTTPPool.ServeHTTP: group.Get(key) failed (getter error, peer fetch failure), and the raw error text is written as the response body before protobuf marshaling is reached. It fires for any cache-retrieval error during a peer HTTP request.","triggerScenarios":"Thrown at gee-cache/day7-proto-buf/geecache/http.go:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the full error server-side to find the root cause (getter error, peer network failure).","Retry the request; transient peer failures typically resolve on a second attempt.","Map known errors (e.g. key not found) to more precise status codes than 500."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}