{"record":{"id":"8628dba94fb43919","repo":"go-kratos/kratos","slug":"enum-s-range-must-be-greater-than-0-and-less-th","errorCode":null,"errorMessage":"Enum '%s' range must be greater than 0 and less than or equal to 600","messagePattern":"Enum '(.+?)' range must be greater than 0 and less than or equal to 600","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/protoc-gen-go-errors/errors.go","lineNumber":69,"sourceCode":"\tfor _, enum := range file.Enums {\n\t\tif !genErrorsReason(gen, file, g, enum) {\n\t\t\tindex++\n\t\t}\n\t}\n\t// If all enums do not contain 'errors.code', the current file is skipped\n\tif index == 0 {\n\t\tg.Skip()\n\t}\n}\n\nfunc genErrorsReason(_ *protogen.Plugin, _ *protogen.File, g *protogen.GeneratedFile, enum *protogen.Enum) bool {\n\tdefaultCode := proto.GetExtension(enum.Desc.Options(), errors.E_DefaultCode)\n\tcode := 0\n\tif ok := defaultCode.(int32); ok != 0 {\n\t\tcode = int(ok)\n\t}\n\tif code > 600 || code < 0 {\n\t\tpanic(fmt.Sprintf(\"Enum '%s' range must be greater than 0 and less than or equal to 600\", string(enum.Desc.Name())))\n\t}\n\tvar ew errorWrapper\n\tfor _, v := range enum.Values {\n\t\tenumCode := code\n\t\teCode := proto.GetExtension(v.Desc.Options(), errors.E_Code)\n\t\tif ok := eCode.(int32); ok != 0 {\n\t\t\tenumCode = int(ok)\n\t\t}\n\t\t// If the current enumeration does not contain 'errors.code'\n\t\t// or the code value exceeds the range, the current enum will be skipped\n\t\tif enumCode > 600 || enumCode < 0 {\n\t\t\tpanic(fmt.Sprintf(\"Enum '%s' range must be greater than 0 and less than or equal to 600\", string(v.Desc.Name())))\n\t\t}\n\t\tif enumCode == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tcomment := v.Comments.Leading.String()","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/cmd/protoc-gen-go-errors/errors.go#L51-L87","documentation":"Error \"Enum '%s' range must be greater than 0 and less than or equal to 600\" thrown in go-kratos/kratos.","triggerScenarios":"Thrown at cmd/protoc-gen-go-errors/errors.go:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"668db92c2c001e9552594ba5a8aede8456af6d7e","analyzedAt":"2026-08-16T02:07:20.704Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}