{"record":{"id":"b06dd1f242327521","repo":"affaan-m/ECC","slug":"errinvalidinput","errorCode":"ErrInvalidInput","errorMessage":"invalid input","messagePattern":"invalid input","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"skills/golang-patterns/SKILL.md","lineNumber":132,"sourceCode":"\n### Custom Error Types\n\n```go\n// Define domain-specific errors\ntype ValidationError struct {\n    Field   string\n    Message string\n}\n\nfunc (e *ValidationError) Error() string {\n    return fmt.Sprintf(\"validation failed on %s: %s\", e.Field, e.Message)\n}\n\n// Sentinel errors for common cases\nvar (\n    ErrNotFound     = errors.New(\"resource not found\")\n    ErrUnauthorized = errors.New(\"unauthorized\")\n    ErrInvalidInput = errors.New(\"invalid input\")\n)\n```\n\n### Error Checking with errors.Is and errors.As\n\n```go\nfunc HandleError(err error) {\n    // Check for specific error\n    if errors.Is(err, sql.ErrNoRows) {\n        log.Println(\"No records found\")\n        return\n    }\n\n    // Check for error type\n    var validationErr *ValidationError\n    if errors.As(err, &validationErr) {\n        log.Printf(\"Validation error on field %s: %s\",\n            validationErr.Field, validationErr.Message)","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/affaan-m/ECC/blob/06c5e118c4d3e6c3b7f9445f973a2194c82de193/skills/golang-patterns/SKILL.md#L114-L150","documentation":"Sentinel error example in the golang-patterns skill documentation: ErrInvalidInput is the idiomatic Go sentinel for rejected request data, compared with errors.Is. Mirrored in the es and ja-JP translations; documentation code, not a runtime throw site.","triggerScenarios":"Thrown at skills/golang-patterns/SKILL.md:132 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the input against the expected schema before submission; correct malformed or out-of-range fields.","Log the rejected value at the boundary so the caller can see which field failed validation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06c5e118c4d3e6c3b7f9445f973a2194c82de193","analyzedAt":"2026-08-18T11:27:13.915Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}