{"record":{"id":"08004d8ae4737d44","repo":"antonmedv/fx","slug":"s-on-line-d-s","errorCode":null,"errorMessage":"%s on line %d.\n\n%s\n","messagePattern":"(.+?) on line (.+?)\\.\n\n(.+?)\n","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/jsonx/format_err.go","lineNumber":30,"sourceCode":"\nfunc (p *JsonParser) errorSnippet(message string) error {\n\ttermWidth, _, err := term.GetSize(os.Stdout.Fd())\n\tif err != nil {\n\t\ttermWidth = 80\n\t}\n\tmaxWidth := min(termWidth, 60)\n\tmaxWidth -= 2\n\tmaxWidth = max(maxWidth, 10)\n\n\t// As we already moved end pointer in next(), we need to move it back.\n\tp.end -= 1\n\n\tbefore, width := p.contextBefore(maxWidth / 2)\n\tafter, _ := p.contextAfter(maxWidth - width)\n\tsnippet := \"  \" + before + after\n\tsnippet += \"\\n  \" + strings.Repeat(\".\", max(0, width-1)) + \"^\"\n\n\treturn fmt.Errorf(\n\t\t\"%s on line %d.\\n\\n%s\\n\",\n\t\tmessage,\n\t\tp.realLineNumber,\n\t\tsnippet,\n\t)\n}\n\nfunc (p *JsonParser) contextBefore(maxWidth int) (s string, width int) {\n\tpos := p.end + 1\n\tif pos > len(p.data) {\n\t\tpos = len(p.data)\n\t}\n\tdata := p.data[:pos]\n\tfor len(data) > 0 {\n\t\tr, size := utf8.DecodeLastRune(data)\n\t\tif r == '\\n' {\n\t\t\tbreak\n\t\t}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/antonmedv/fx/blob/4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe/internal/jsonx/format_err.go#L12-L48","documentation":"Formats the human-readable parse error shown for invalid JSON input: it builds a caret-pointing snippet of the offending line (width clamped to terminal size, defaulting to 80 columns) and embeds the parser message with its line number. This is a formatting helper, not an independent failure — the message reflects whatever JSON syntax error the parser hit.","triggerScenarios":"Thrown at internal/jsonx/format_err.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the JSON syntax at the indicated line and column in the input","Validate the JSON with a linter before feeding it to fx","Check for truncated files or stray characters around the marked caret"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe","analyzedAt":"2026-09-02T02:17:47.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}